-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename
custom-typeshed-dir
, target-version
and `current-directory…
…` CLI options (#14930) ## 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 ``` An extremely fast Python type checker. Usage: red_knot [OPTIONS] [COMMAND] Commands: server Start the language server help Print this message or the help of the given subcommand(s) Options: --project <PROJECT> 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, as will the project's virtual environment (`.venv`). Other command-line arguments (such as relative paths) will be resolved relative to the current working directory."#, --venv-path <PATH> Path to the virtual environment the project uses. If provided, red-knot will use the `site-packages` directory of this virtual environment to resolve type information for the project's third-party dependencies. --typeshed-path <PATH> Custom directory to use for stdlib typeshed stubs --extra-search-path <PATH> Additional path to use as a module-resolution source (can be passed multiple times) --python-version <VERSION> Python version to assume when resolving types [possible values: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13] -v, --verbose... Use verbose output (or `-vv` and `-vvv` for more verbose output) -W, --watch Run in watch mode by re-running whenever files change -h, --help Print help (see a summary with '-h') -V, --version Print version ``` Short help ``` An extremely fast Python type checker. Usage: red_knot [OPTIONS] [COMMAND] Commands: server Start the language server help Print this message or the help of the given subcommand(s) Options: --project <PROJECT> Run the command within the given project directory --venv-path <PATH> Path to the virtual environment the project uses --typeshed-path <PATH> Custom directory to use for stdlib typeshed stubs --extra-search-path <PATH> Additional path to use as a module-resolution source (can be passed multiple times) --python-version <VERSION> Python version to assume when resolving types [possible values: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13] -v, --verbose... Use verbose output (or `-vv` and `-vvv` for more verbose output) -W, --watch Run in watch mode by re-running whenever files change -h, --help Print help (see more with '--help') -V, --version Print version ``` --------- Co-authored-by: Alex Waygood <[email protected]>
- Loading branch information
1 parent
d7ce548
commit c1837e4
Showing
33 changed files
with
282 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/// Enumeration of all supported Python versions | ||
/// | ||
/// TODO: unify with the `PythonVersion` enum in the linter/formatter crates? | ||
#[derive(Copy, Clone, Hash, Debug, PartialEq, Eq, PartialOrd, Ord, Default, clap::ValueEnum)] | ||
pub enum PythonVersion { | ||
#[value(name = "3.7")] | ||
Py37, | ||
#[value(name = "3.8")] | ||
Py38, | ||
#[default] | ||
#[value(name = "3.9")] | ||
Py39, | ||
#[value(name = "3.10")] | ||
Py310, | ||
#[value(name = "3.11")] | ||
Py311, | ||
#[value(name = "3.12")] | ||
Py312, | ||
#[value(name = "3.13")] | ||
Py313, | ||
} | ||
|
||
impl PythonVersion { | ||
const fn as_str(self) -> &'static str { | ||
match self { | ||
Self::Py37 => "3.7", | ||
Self::Py38 => "3.8", | ||
Self::Py39 => "3.9", | ||
Self::Py310 => "3.10", | ||
Self::Py311 => "3.11", | ||
Self::Py312 => "3.12", | ||
Self::Py313 => "3.13", | ||
} | ||
} | ||
} | ||
|
||
impl std::fmt::Display for PythonVersion { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.write_str(self.as_str()) | ||
} | ||
} | ||
|
||
impl From<PythonVersion> for red_knot_python_semantic::PythonVersion { | ||
fn from(value: PythonVersion) -> Self { | ||
match value { | ||
PythonVersion::Py37 => Self::PY37, | ||
PythonVersion::Py38 => Self::PY38, | ||
PythonVersion::Py39 => Self::PY39, | ||
PythonVersion::Py310 => Self::PY310, | ||
PythonVersion::Py311 => Self::PY311, | ||
PythonVersion::Py312 => Self::PY312, | ||
PythonVersion::Py313 => Self::PY313, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::python_version::PythonVersion; | ||
|
||
#[test] | ||
fn same_default_as_python_version() { | ||
assert_eq!( | ||
red_knot_python_semantic::PythonVersion::from(PythonVersion::default()), | ||
red_knot_python_semantic::PythonVersion::default() | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ def f(): | |
|
||
```toml | ||
[environment] | ||
target-version = "3.11" | ||
python-version = "3.11" | ||
``` | ||
|
||
```py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.