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 return type for SymbolTable.get_identifiers #8054

Merged
merged 2 commits into from
Jun 10, 2022

Conversation

pamelafox
Copy link
Contributor

Per my PR to cpython (python/cpython#93661), the documentation for SymbolTable.get_identifiers incorrectly says it returns a list, and thats what typeshed currently says as well.

This PR changes it to return dict_keys[str, int]

Here's code that shows get_identifiers in action:

>>> import symtable
>>> code = """
... def calc_pow(a, b):
...     return a ** b
... a = 1
... b = 2
... c = calc_pow(a,b)
... """
>>> 
>>> _st = symtable.symtable(code, "example.py", "exec")
>>> _st.get_identifiers()
dict_keys(['calc_pow', 'a', 'b', 'c'])
>>> _st.get_identifiers().mapping
mappingproxy({'calc_pow': 2066, 'a': 2066, 'b': 2066, 'c': 2050})

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@srittau srittau merged commit b4c3e2c into python:master Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants