Skip to content

Commit

Permalink
Fix deprecations (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored May 15, 2024
1 parent e5f292f commit c55a3b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ call ``resolver.get_fully_qualified_name('collections.Set')`` to retrieve the
Changelog
---------

Unreleased

- Fix warnings due to use of deprecated AST classes

Version 2.5.1 (February 25, 2024)

- Fix packaging metadata that still incorrectly declared support for Python 3.7
Expand Down
2 changes: 1 addition & 1 deletion tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class IntegrationTest(unittest.TestCase):
def test(self) -> None:
ctx = get_search_context(raise_on_warnings=True)
for module_name, module_path in typeshed_client.get_all_stub_files(ctx):
with self.subTest(path=module_name):
with self.subTest(name=module_name, path=module_path):
try:
ast = typeshed_client.get_stub_ast(module_name, search_context=ctx)
except SyntaxError:
Expand Down
8 changes: 5 additions & 3 deletions typeshed_client/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def _get_dunder_all_from_ast(node: ast.AST) -> Optional[List[str]]:
raise InvalidStub(f"Invalid __all__: {ast.dump(rhs)}")
names = []
for elt in rhs.elts:
if not isinstance(elt, ast.Str):
if not isinstance(elt, ast.Constant) or not isinstance(elt.value, str):
raise InvalidStub(f"Invalid __all__: {ast.dump(rhs)}")
names.append(elt.s)
names.append(elt.value)
return names


Expand Down Expand Up @@ -313,7 +313,9 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> Iterable[NameInfo]:
)

def visit_Expr(self, node: ast.Expr) -> Iterable[NameInfo]:
if isinstance(node.value, (ast.Ellipsis, ast.Str)):
if isinstance(node.value, ast.Constant) and (
node.value.value is Ellipsis or isinstance(node.value.value, str)
):
return
dunder_all = self._maybe_extract_dunder_all(node.value)
if dunder_all is not None:
Expand Down

0 comments on commit c55a3b4

Please sign in to comment.