Skip to content

Commit c55a3b4

Browse files
Fix deprecations (#106)
1 parent e5f292f commit c55a3b4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.rst

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ call ``resolver.get_fully_qualified_name('collections.Set')`` to retrieve the
8181
Changelog
8282
---------
8383

84+
Unreleased
85+
86+
- Fix warnings due to use of deprecated AST classes
87+
8488
Version 2.5.1 (February 25, 2024)
8589

8690
- Fix packaging metadata that still incorrectly declared support for Python 3.7

tests/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class IntegrationTest(unittest.TestCase):
334334
def test(self) -> None:
335335
ctx = get_search_context(raise_on_warnings=True)
336336
for module_name, module_path in typeshed_client.get_all_stub_files(ctx):
337-
with self.subTest(path=module_name):
337+
with self.subTest(name=module_name, path=module_path):
338338
try:
339339
ast = typeshed_client.get_stub_ast(module_name, search_context=ctx)
340340
except SyntaxError:

typeshed_client/parser.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ def _get_dunder_all_from_ast(node: ast.AST) -> Optional[List[str]]:
153153
raise InvalidStub(f"Invalid __all__: {ast.dump(rhs)}")
154154
names = []
155155
for elt in rhs.elts:
156-
if not isinstance(elt, ast.Str):
156+
if not isinstance(elt, ast.Constant) or not isinstance(elt.value, str):
157157
raise InvalidStub(f"Invalid __all__: {ast.dump(rhs)}")
158-
names.append(elt.s)
158+
names.append(elt.value)
159159
return names
160160

161161

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

315315
def visit_Expr(self, node: ast.Expr) -> Iterable[NameInfo]:
316-
if isinstance(node.value, (ast.Ellipsis, ast.Str)):
316+
if isinstance(node.value, ast.Constant) and (
317+
node.value.value is Ellipsis or isinstance(node.value.value, str)
318+
):
317319
return
318320
dunder_all = self._maybe_extract_dunder_all(node.value)
319321
if dunder_all is not None:

0 commit comments

Comments
 (0)