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

Remove several unused imports in _pyrepl #118668

Merged
merged 1 commit into from
May 7, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented May 6, 2024

No description provided.

Copy link
Member

@Eclips4 Eclips4 left a comment

Choose a reason for hiding this comment

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

LGTM!
Also, if we can do a little bit of refactoring (Not in this PR), can we replace if False: ... with a if TYPE_CHECKING: ...? This if False: ... entries looks weird for me.

@sobolevn
Copy link
Member Author

sobolevn commented May 6, 2024

TYPE_CHECKING needs typing import which is slow. Import time is critical for REPLs :(

@Eclips4
Copy link
Member

Eclips4 commented May 6, 2024

TYPE_CHECKING needs typing import which is slow. Import time is critical for REPLs :(

Oh, I forgot about that. Then let's leave it as it is.

@denballakh
Copy link
Contributor

denballakh commented May 6, 2024

There is a way to do if TYPE_CHECKING check without importing typing:

MYPY = False
if MYPY: # False at runtime, but mypy thinks that it is True
  ... # do expensive stuff

It should be configured using these options:

> mypy -h
...
  --always-true NAME        Additional variable to be considered True (may be
                            repeated)
  --always-false NAME       Additional variable to be considered False (may be
                            repeated)
...

Copy link
Contributor

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

LGTM!

@pablogsal pablogsal merged commit ad3d877 into python:main May 7, 2024
44 checks passed
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
@ambv ambv added the topic-repl Related to the interactive shell label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue skip news topic-repl Related to the interactive shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants