Compare commits

...

5 Commits

Author SHA1 Message Date
dylwil3
8bda1837d9 update tests and snapshots 2025-06-06 09:28:47 -05:00
dylwil3
e667d53828 update docs 2025-06-06 09:28:47 -05:00
dylwil3
a071114638 remove preview check for rule 2025-06-06 09:28:47 -05:00
Brent Westbrook
86ae9fbc08 Ruff 0.12
Summary
--

Release branch for Ruff 0.12.0

TODOs
--

- [ ] Drop empty first commit
- [ ] Merge with rebase-merge (**don't squash merge!!!!**)
2025-06-06 09:28:47 -05:00
Brent Westbrook
11966beeec Ruff 0.12
Summary
--

Release branch for Ruff 0.12.0

TODOs
--

- [ ] Drop empty first commit
- [ ] Merge with rebase-merge (**don't squash merge!!!!**)
2025-06-06 10:14:43 -04:00
7 changed files with 34 additions and 47 deletions

View File

@@ -65,7 +65,7 @@ use crate::docstrings::extraction::ExtractionTarget;
use crate::importer::{ImportRequest, Importer, ResolutionError};
use crate::noqa::NoqaMapping;
use crate::package::PackageRoot;
use crate::preview::{is_semantic_errors_enabled, is_undefined_export_in_dunder_init_enabled};
use crate::preview::is_semantic_errors_enabled;
use crate::registry::{AsRule, Rule};
use crate::rules::pyflakes::rules::{
LateFutureImport, ReturnOutsideFunction, YieldOutsideFunction,
@@ -2900,17 +2900,13 @@ impl<'a> Checker<'a> {
}
} else {
if self.enabled(Rule::UndefinedExport) {
if is_undefined_export_in_dunder_init_enabled(self.settings)
|| !self.path.ends_with("__init__.py")
{
self.report_diagnostic(
pyflakes::rules::UndefinedExport {
name: name.to_string(),
},
range,
)
.set_parent(definition.start());
}
self.report_diagnostic(
pyflakes::rules::UndefinedExport {
name: name.to_string(),
},
range,
)
.set_parent(definition.start());
}
}
}

View File

@@ -111,11 +111,6 @@ pub(crate) const fn is_support_slices_in_literal_concatenation_enabled(
settings.preview.is_enabled()
}
// https://github.com/astral-sh/ruff/pull/11370
pub(crate) const fn is_undefined_export_in_dunder_init_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()
}
// https://github.com/astral-sh/ruff/pull/14236
pub(crate) const fn is_allow_nested_roots_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()

View File

@@ -233,7 +233,6 @@ mod tests {
#[test_case(Rule::UnusedImport, Path::new("F401_27__all_mistyped/__init__.py"))]
#[test_case(Rule::UnusedImport, Path::new("F401_28__all_multiple/__init__.py"))]
#[test_case(Rule::UnusedImport, Path::new("F401_29__all_conditional/__init__.py"))]
#[test_case(Rule::UndefinedExport, Path::new("__init__.py"))]
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!(
"preview__{}_{}",

View File

@@ -14,7 +14,7 @@ use crate::Violation;
/// Including an undefined name in `__all__` is likely to raise `NameError` at
/// runtime, when the module is imported.
///
/// In [preview], this rule will flag undefined names in `__init__.py` file,
/// This rule will flag undefined names in `__init__.py` file
/// even if those names implicitly refer to other modules in the package. Users
/// that rely on implicit exports should disable this rule in `__init__.py`
/// files via [`lint.per-file-ignores`].
@@ -37,8 +37,6 @@ use crate::Violation;
///
/// ## References
/// - [Python documentation: `__all__`](https://docs.python.org/3/tutorial/modules.html#importing-from-a-package)
///
/// [preview]: https://docs.astral.sh/ruff/preview/
#[derive(ViolationMetadata)]
pub(crate) struct UndefinedExport {
pub name: String,

View File

@@ -9,3 +9,27 @@ __init__.py:1:8: F401 `os` imported but unused
3 | print(__path__)
|
= help: Remove unused import: `os`
__init__.py:5:12: F822 Undefined name `a` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|
__init__.py:5:17: F822 Undefined name `b` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|
__init__.py:5:22: F822 Undefined name `c` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|

View File

@@ -1,26 +0,0 @@
---
source: crates/ruff_linter/src/rules/pyflakes/mod.rs
---
__init__.py:5:12: F822 Undefined name `a` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|
__init__.py:5:17: F822 Undefined name `b` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|
__init__.py:5:22: F822 Undefined name `c` in `__all__`
|
3 | print(__path__)
4 |
5 | __all__ = ["a", "b", "c"]
| ^^^ F822
|

View File

@@ -7,6 +7,7 @@ use ruff_python_semantic::analyze::function_type::is_stub;
use crate::Violation;
use crate::checkers::ast::Checker;
use crate::rules::fastapi::rules::is_fastapi_route;
/// ## What it does