8000 Use Final instead of Literal in logging by srittau · Pull Request #7259 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Use Final instead of Literal in logging #7259

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

Closed
wants to merge 2 commits into from

Conversation

srittau
Copy link
Collaborator
@srittau srittau commented Feb 18, 2022

No description provided.

@srittau
Copy link
Collaborator Author
srittau commented Feb 18, 2022

Test for #7258

@Akuli
Copy link
Collaborator
Akuli commented Feb 18, 2022

You need to import Final.

@srittau
Copy link
Collaborator Author
srittau commented Feb 18, 2022

The flake8 error was expected, the pytype one not.

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

An encouraging primer output, however

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pip (https://github.com/pypa/pip)
- src/pip/_internal/locations/__init__.py:68: error: Incompatible types in assignment (expression has type "Literal[10]", variable has type "Literal[30]")
- src/pip/_internal/utils/logging.py:231: error: Incompatible types in assignment (expression has type "int", variable has type "Literal[10]")
- src/pip/_internal/utils/logging.py:233: error: Incompatible types in assignment (expression has type "Literal[30]", variable has type "Literal[10]")
- src/pip/_internal/utils/logging.py:235: error: Incompatible types in assignment (expression has type "Literal[40]", variable has type "Literal[10]")
- src/pip/_internal/utils/logging.py:237: error: Incompatible types in assignment (expression has type "Literal[50]", variable has type "Literal[10]")
- src/pip/_internal/utils/logging.py:239: error: Incompatible types in assignment (expression has type "Literal[20]", variable has type "Literal[10]")
- src/pip/_internal/utils/subprocess.py:125: error: Incompatible types in assignment (expression has type "int", variable has type "Literal[20]")

streamlit (https://github.com/streamlit/streamlit)
- lib/streamlit/logger.py: note: In function "set_log_level":
- lib/streamlit/logger.py:41:21: error: Incompatible types in assignment (expression has type "Literal[40]", variable has type "Literal[50]")  [assignment]
- lib/streamlit/logger.py:43:21: error: Incompatible types in assignment (expression has type "Literal[30]", variable has type "Literal[50]")  [assignment]
- lib/streamlit/logger.py:45:21: error: Incompatible types in assignment (expression has type "Literal[20]", variable has type "Literal[50]")  [assignment]
- lib/streamlit/logger.py:47:21: error: Incompatible types in assignment (expression has type "Literal[10]", variable has type "Literal[50]")  [assignment]
- lib/streamlit/logger.py:57:17: error: Incompatible types in assignment (expression has type "Literal[50]", variable has type "Literal[20]")  [assignment]

@hauntsaninja
Copy link
Collaborator

mypy_primer did tell us this was going to be a problem in #6610 and we merged, acknowledging that we might want to revert later. Maybe this question isn't meaningful, but do we feel like "this is things going to plan: we tried a thing, it didn't work" or should we update in the direction of being less likely to merge past primer issues?

@srittau
Copy link
Collaborator Author
srittau commented Feb 22, 2022

Closing due to the discussion in #7258.

@srittau srittau closed this Feb 22, 2022
@srittau srittau deleted the final-literal-test branch February 22, 2022 11:25
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.

4 participants
0