-
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.
Merge branch 'main' into dcreager/generate-ast
* main: [red-knot] Inline `SubclassOfType::as_instance_type_of_metaclass()` (#15556) [`flake8-comprehensions`] strip parentheses around generators in `unnecessary-generator-set` (`C401`) (#15553) [`pylint`] Implement `redefined-slots-in-subclass` (`W0244`) (#9640) [`flake8-bugbear`] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (`B903`) (#15549) [red-knot] `type[T]` is disjoint from `type[S]` if the metaclass of `T` is disjoint from the metaclass of `S` (#15547) [red-knot] Pure instance variables declared in class body (#15515) Update snapshots of #15507 with new annotated snipetts rendering (#15546) [`pylint`] Do not report methods with only one `EM101`-compatible `raise` (`PLR6301`) (#15507) Fix unstable f-string formatting for expressions containing a trailing comma (#15545) Support `knot.toml` files in project discovery (#15505) Add support for configuring knot in `pyproject.toml` files (#15493) Fix bracket spacing for single-element tuples in f-string expressions (#15537) [`flake8-simplify`] Do not emit diagnostics for expressions inside string type annotations (`SIM222`, `SIM223`) (#15405) [`flake8-pytest-style`] Do not emit diagnostics for empty `for` loops (`PT012`, `PT031`) (#15542)
- Loading branch information
Showing
84 changed files
with
2,465 additions
and
540 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use anyhow::Context; | ||
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; | ||
use std::process::Command; | ||
use tempfile::TempDir; | ||
|
||
/// Specifying an option on the CLI should take precedence over the same setting in the | ||
/// project's configuration. | ||
#[test] | ||
fn test_config_override() -> anyhow::Result<()> { | ||
let tempdir = TempDir::new()?; | ||
|
||
std::fs::write( | ||
tempdir.path().join("pyproject.toml"), | ||
r#" | ||
[tool.knot.environment] | ||
python-version = "3.11" | ||
"#, | ||
) | ||
.context("Failed to write settings")?; | ||
|
||
std::fs::write( | ||
tempdir.path().join("test.py"), | ||
r#" | ||
import sys | ||
# Access `sys.last_exc` that was only added in Python 3.12 | ||
print(sys.last_exc) | ||
"#, | ||
) | ||
.context("Failed to write test.py")?; | ||
|
||
insta::with_settings!({filters => vec![(&*tempdir_filter(&tempdir), "<temp_dir>/")]}, { | ||
assert_cmd_snapshot!(knot().arg("--project").arg(tempdir.path()), @r" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
error[lint:unresolved-attribute] <temp_dir>/test.py:5:7 Type `<module 'sys'>` has no attribute `last_exc` | ||
----- stderr ----- | ||
"); | ||
}); | ||
|
||
assert_cmd_snapshot!(knot().arg("--project").arg(tempdir.path()).arg("--python-version").arg("3.12"), @r" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
----- stderr ----- | ||
"); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn knot() -> Command { | ||
Command::new(get_cargo_bin("red_knot")) | ||
} | ||
|
||
fn tempdir_filter(tempdir: &TempDir) -> String { | ||
format!(r"{}\\?/?", regex::escape(tempdir.path().to_str().unwrap())) | ||
} |
Oops, something went wrong.