-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-129758: Correct imports in Lib/_pyrepl #129761
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
Conversation
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.
I agree that changing if False
to TYPE_CHECKING = False; if TYPE_CHECKING
makes sense, because mypy better understands the second version.
See https://mypy-play.net/?mypy=latest&python=3.12&flags=strict%2Cwarn-unreachable&gist=ba9b71e677d20a0b4c1f78c731c0c0ea for if False
:
main.py:4: error: Statement is unreachable [unreachable]
And see https://mypy-play.net/?mypy=latest&python=3.12&flags=strict%2Cwarn-unreachable&gist=c84fabb19a5b4a92b6eee9656b978baa for if TYPE_CHECKING
:
Succeeded!! (3383 ms)
So, basically - changing if False
-> if TYPE_CHECKING
is required to enable warn_unreachable = true
.
But, I am against changing anything else. Let's no refactor other places, like moving imports or renaming things. It will just create more friction for no gain.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
it's probably worth leaving the removal of I also removed And the last one I removed import ctypes # so i removed this import
...
from ctypes import Structure
...
class CHAR_INFO(Structure):
...
class KeyEvent(ctypes.Structure): # and fix here: ctypes.Structure -> Structure
... |
I have made the requested changes; please review again |
Thanks for making the requested changes! @sobolevn: please review the changes made to this pull request. |
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.
I've left several suggestions to minimize the final diff. Every line counts 😉
We should be very careful about what we change and what we don't change.
Thank you!
*, | ||
future_flags: int = 0, | ||
) -> None: | ||
from .readline import _setup |
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.
Please, don't change this line.
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.
@sobolevn ok, but why? We already have import _setup
on 34 line
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, the default position is the status quo, you need to justify every change.
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.
I removed it because it duplicates imports. As I already said it is on line 34
Co-authored-by: sobolevn <[email protected]>
Co-authored-by: sobolevn <[email protected]>
Co-authored-by: sobolevn <[email protected]>
Co-authored-by: sobolevn <[email protected]>
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.
I agree that changing if False to TYPE_CHECKING = False; if TYPE_CHECKING makes sense, because mypy better understands the second version.
@sobolevn is it feasible to add a config option to mypy
to have it recognise if False
as the same as if TYPE_CHECKING
?
We have the same idiom in several places, and if it leaks further then we will have a lot of useless module-level constants, whereas if False
is optimised away by the interpreter. I'd prefer to wait for mypy to release a new version with this new option, rather than to change code here needlessly (it also attracts a lot of low value contributions because "<tool> has warnings" etc).
A
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Adam Turner <[email protected]>
I have made the requested changes; please review again |
Thanks for making the requested changes! @sobolevn, @AA-Turner: please review the changes made to this pull request. |
Thanks, but we won't be taking this. This is churn. |
Lib/_pyrepl
#129758