Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecations #106

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading