Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
JelleZijlstra and vstinner authored Sep 24, 2024
1 parent fefa126 commit ab30124
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Lib/annotationlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,10 @@ def __convert_to_ast(self, other):
return ast.Constant(value=other)

def __get_ast(self):
if isinstance(self.__ast_node__, str):
return ast.Name(id=self.__ast_node__)
return self.__ast_node__
node = self.__ast_node__
if isinstance(node, str):
return ast.Name(id=node)
return node

def __make_new(self, node):
return _Stringifier(
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_annotationlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ class Gen[T]:
def test_fwdref_with_module(self):
self.assertIs(ForwardRef("Format", module="annotationlib").evaluate(), Format)
self.assertIs(
ForwardRef("Counter", module="collections").evaluate(), collections.Counter
ForwardRef("Counter", module="collections").evaluate(),
collections.Counter
)
self.assertEqual(
ForwardRef("Counter[int]", module="collections").evaluate(),
Expand Down

0 comments on commit ab30124

Please sign in to comment.