-
-
Couldn't load subscription status.
- Fork 459
Add some typing changes required by Mypyc #1658
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| import platform | ||
| import sys | ||
|
|
||
| from typing import Any | ||
| from typing import Any, Final | ||
| from collections.abc import Iterable | ||
|
|
||
| # debug_info() at the bottom wants to show all the globals, but not imports. | ||
|
|
@@ -53,10 +53,7 @@ class PYBEHAVIOR: | |
|
|
||
| # Is "if not __debug__" optimized away? The exact details have changed | ||
| # across versions. | ||
| if pep626: | ||
| optimize_if_not_debug = 1 | ||
| else: | ||
| optimize_if_not_debug = 2 | ||
| optimize_if_not_debug = 1 if pep626 else 2 | ||
|
|
||
| # 3.7 changed how functions with only docstrings are numbered. | ||
| docstring_only_function = (not PYPY) and (PYVERSION <= (3, 10)) | ||
|
|
@@ -148,7 +145,7 @@ class PYBEHAVIOR: | |
| soft_keywords = (PYVERSION >= (3, 10)) | ||
|
|
||
| # PEP669 Low Impact Monitoring: https://peps.python.org/pep-0669/ | ||
| pep669 = bool(getattr(sys, "monitoring", None)) | ||
| pep669: Final[bool] = bool(getattr(sys, "monitoring", None)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conceptually, all of PYBEHAVIOR should be Final. How come only this attribute needed Final? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good question. I think it has to do with the file exclusions I mentioned above. Probably they would all require |
||
|
|
||
| # Where does frame.f_lasti point when yielding from a generator? | ||
| # It used to point at the YIELD, in 3.13 it points at the RESUME, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general Mypyc doesn't things being defined in multiple places. Using
if/elsemeans the class var is defined in two places, while using conditional statement means it is defined in just one place.A more dramatic example is in
files.py, where the functionactual_pathis defined conditionally: