-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Rename custom-typeshed-dir
, target-version
and current-directory
CLI options
#14930
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 still sorta think target-version
more clearly communicates that it should be the Python version your code is targeting, which could be very different to the Python version you're using for local development. But hopefully we can address this with excellent documentation.
Co-authored-by: Alex Waygood <[email protected]>
9d05782
to
aa63ffa
Compare
Co-authored-by: Alex Waygood <[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.
Thanks. Looking forward to not having to type --current-directory
anymore.
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.
LGTM!
crates/red_knot/src/main.rs
Outdated
)] | ||
/// Run the command within the given project directory. | ||
/// | ||
/// All `pyproject.toml` files will be discovered by walking up the directory tree from the project root, |
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 find this sentence a bit confusing, because I thought the "project root" is defined by where we find a pyproject.toml
with the expected config? It might make more sense to phrase this as something like "The project root will be found relative to this directory" or similar?
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.
Fair, I copied this from uv 🤭
I don't really understand what the potential confusion would be here. If you are telling a type checker your Python version, what other meaning could there be other than "please typecheck this code for this Python version"? I guess I think it's totally fine if in simple cases people conflate "Python version I'm using for local development" with "Python version this code is targeting" -- wanting to separate those is a slightly more advanced use case, and I just don't see any likelihood that anyone who needs to separate those two will be confused about what It has the advantage over |
I obviously don't feel strongly, or I wouldn't have approved!
I think the potential confusion is that users might not understand why we need this setting at all, given that we already have other settings with which users can tell us the path to the Python executable they're using. If we always used the local-development Python version, we could just derive this information from that setting. But the setting doesn't really mean that at all -- it means "Please specify the minimum Python version you expect this app/library to support (not necessarily the version you're running now), so that we can emit errors if you use features or syntax that are newer than that".
It doesn't seem that advanced to me. I think it's pretty common that people use a version of Python for local development that's pretty new, but they nonetheless want it to be possible for other users to run their code on older versions of Python as well.
I can't recall anybody ever being confused about this on the Ruff issue tracker (Ruff uses |
I don't feel strongly either! Just trying to understand what I'm missing about the arguments either way.
One answer to this is simply that we want to avoid running a Python executable as part of red-knot settings derivation, and there's no reliable way to tell the Python version of a Python executable without running it. If there were such a way, I would be in favor of automatically deriving the Python version from the executable we are pointed towards, if a version isn't explicitly given.
Fair enough, that's certainly relevant data! |
I expect most users will use I also think that the setting is clearer because it is in However, I agree with you that we could also just derive the value from |
* main: [red-knot] Display definition range in trace logs (#14955) [red-knot] Move the `ClassBase` enum to its own submodule (#14957) [red-knot] mdtest: python version requirements (#14954) [airflow]: Import modules that has been moved to airflow providers (AIR303) (#14764) [red-knot] Support `typing.TYPE_CHECKING` (#14952) Add tracing support to mdtest (#14935) Re-enable the fuzzer job on PRs (#14953) [red-knot] Improve `match` mdtests (#14951) Rename `custom-typeshed-dir`, `target-version` and `current-directory` CLI options (#14930) [red-knot] Add narrowing for 'while' loops (#14947) [`ruff`] Skip SQLModel base classes for `mutable-class-default` (`RUF012`) (#14949) [red-knot] Tests for 'while' loop boundness (#14944)
Summary
This PR renames the
--custom-typeshed-dir
,target-version
, and--current-directory
cli options to--typeshed
,--python-version
, and--project
as discussed in the CLI proposal document.I added aliases for
--target-version
(for Ruff compat) and--custom-typeshed-dir
(for Alex)Test Plan
Long help
Short help