Skip to content

Commit

Permalink
Remove keep-runtime-typing setting
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed May 14, 2023
1 parent 01b372a commit f3ed25c
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 103 deletions.
9 changes: 9 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Breaking Changes

## 0.0.268

### The `keep-runtime-typing` setting has been removed ([#4427](https://github.com/charliermarsh/ruff/pull/4427))

Enabling the `keep-runtime-typing` option, located under the `pyupgrade` section, is equivalent
to ignoring the `UP006` and `UP007` rules via Ruff's standard `ignore` mechanism. As there's no
need for a dedicated setting to disable these rules, the `keep-runtime-typing` option has been
removed.

## 0.0.267

### `update-check` is no longer a valid configuration option ([#4313](https://github.com/charliermarsh/ruff/pull/4313))
Expand Down
9 changes: 3 additions & 6 deletions crates/ruff/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2269,8 +2269,7 @@ where
{
flake8_future_annotations::rules::missing_future_annotations(self, value);
}
if !self.settings.pyupgrade.keep_runtime_typing
&& self.settings.rules.enabled(Rule::NonPEP604Annotation)
if self.settings.rules.enabled(Rule::NonPEP604Annotation)
&& (self.settings.target_version >= PythonVersion::Py310
|| (self.settings.target_version >= PythonVersion::Py37
&& self.ctx.future_annotations()
Expand Down Expand Up @@ -2347,8 +2346,7 @@ where
self, expr,
);
}
if !self.settings.pyupgrade.keep_runtime_typing
&& self.settings.rules.enabled(Rule::NonPEP585Annotation)
if self.settings.rules.enabled(Rule::NonPEP585Annotation)
&& (self.settings.target_version >= PythonVersion::Py39
|| (self.settings.target_version >= PythonVersion::Py37
&& self.ctx.future_annotations()
Expand Down Expand Up @@ -2410,8 +2408,7 @@ where
{
flake8_future_annotations::rules::missing_future_annotations(self, expr);
}
if !self.settings.pyupgrade.keep_runtime_typing
&& self.settings.rules.enabled(Rule::NonPEP585Annotation)
if self.settings.rules.enabled(Rule::NonPEP585Annotation)
&& (self.settings.target_version >= PythonVersion::Py39
|| (self.settings.target_version >= PythonVersion::Py37
&& self.ctx.future_annotations()
Expand Down
1 change: 0 additions & 1 deletion crates/ruff/src/rules/pyupgrade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
mod fixes;
mod helpers;
pub(crate) mod rules;
pub mod settings;
pub(crate) mod types;

#[cfg(test)]
Expand Down
51 changes: 0 additions & 51 deletions crates/ruff/src/rules/pyupgrade/settings.rs

This file was deleted.

4 changes: 0 additions & 4 deletions crates/ruff/src/settings/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::rules::{
flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions,
flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking,
flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pylint,
pyupgrade,
};
use crate::settings::options::Options;
use crate::settings::types::{
Expand Down Expand Up @@ -87,7 +86,6 @@ pub struct Configuration {
pub pycodestyle: Option<pycodestyle::settings::Options>,
pub pydocstyle: Option<pydocstyle::settings::Options>,
pub pylint: Option<pylint::settings::Options>,
pub pyupgrade: Option<pyupgrade::settings::Options>,
}

impl Configuration {
Expand Down Expand Up @@ -222,7 +220,6 @@ impl Configuration {
pycodestyle: options.pycodestyle,
pydocstyle: options.pydocstyle,
pylint: options.pylint,
pyupgrade: options.pyupgrade,
})
}

Expand Down Expand Up @@ -298,7 +295,6 @@ impl Configuration {
pycodestyle: self.pycodestyle.or(config.pycodestyle),
pydocstyle: self.pydocstyle.or(config.pydocstyle),
pylint: self.pylint.or(config.pylint),
pyupgrade: self.pyupgrade.or(config.pyupgrade),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/ruff/src/settings/defaults.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::collections::HashSet;

use once_cell::sync::Lazy;
use path_absolutize::path_dedot;
use regex::Regex;
use rustc_hash::FxHashSet;
use std::collections::HashSet;

use super::types::{FilePattern, PythonVersion};
use super::Settings;
use crate::codes::{self, RuleCodePrefix};
use crate::registry::Linter;
use crate::rule_selector::{prefix_to_selector, RuleSelector};
Expand All @@ -14,10 +13,12 @@ use crate::rules::{
flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions,
flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking,
flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pylint,
pyupgrade,
};
use crate::settings::types::FilePatternSet;

use super::types::{FilePattern, PythonVersion};
use super::Settings;

pub const PREFIXES: &[RuleSelector] = &[
prefix_to_selector(RuleCodePrefix::Pycodestyle(codes::Pycodestyle::E)),
RuleSelector::Linter(Linter::Pyflakes),
Expand Down Expand Up @@ -105,7 +106,6 @@ impl Default for Settings {
pycodestyle: pycodestyle::settings::Settings::default(),
pydocstyle: pydocstyle::settings::Settings::default(),
pylint: pylint::settings::Settings::default(),
pyupgrade: pyupgrade::settings::Settings::default(),
}
}
}
3 changes: 0 additions & 3 deletions crates/ruff/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::rules::{
flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions,
flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking,
flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pylint,
pyupgrade,
};
use crate::settings::configuration::Configuration;
use crate::settings::types::{FilePatternSet, PerFileIgnore, PythonVersion, SerializationFormat};
Expand Down Expand Up @@ -126,7 +125,6 @@ pub struct Settings {
pub pycodestyle: pycodestyle::settings::Settings,
pub pydocstyle: pydocstyle::settings::Settings,
pub pylint: pylint::settings::Settings,
pub pyupgrade: pyupgrade::settings::Settings,
}

impl Settings {
Expand Down Expand Up @@ -226,7 +224,6 @@ impl Settings {
pycodestyle: config.pycodestyle.map(Into::into).unwrap_or_default(),
pydocstyle: config.pydocstyle.map(Into::into).unwrap_or_default(),
pylint: config.pylint.map(Into::into).unwrap_or_default(),
pyupgrade: config.pyupgrade.map(Into::into).unwrap_or_default(),
})
}

Expand Down
12 changes: 5 additions & 7 deletions crates/ruff/src/settings/options.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
//! Options that the user can provide via pyproject.toml.

use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};

use ruff_macros::ConfigurationOptions;

use crate::rule_selector::RuleSelector;
use crate::rules::{
flake8_annotations, flake8_bandit, flake8_bugbear, flake8_builtins, flake8_comprehensions,
flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions,
flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking,
flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pylint,
pyupgrade,
};
use crate::settings::types::{PythonVersion, SerializationFormat, Version};
use ruff_macros::ConfigurationOptions;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Default, ConfigurationOptions)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
Expand Down Expand Up @@ -508,9 +509,6 @@ pub struct Options {
#[option_group]
/// Options for the `pylint` plugin.
pub pylint: Option<pylint::settings::Options>,
#[option_group]
/// Options for the `pyupgrade` plugin.
pub pyupgrade: Option<pyupgrade::settings::Options>,
// Tables are required to go last.
#[option(
default = "{}",
Expand Down
2 changes: 0 additions & 2 deletions crates/ruff_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use ruff::rules::{
flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions,
flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking,
flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pylint,
pyupgrade,
};
use ruff::settings::configuration::Configuration;
use ruff::settings::options::Options;
Expand Down Expand Up @@ -155,7 +154,6 @@ pub fn defaultSettings() -> Result<JsValue, JsValue> {
pycodestyle: Some(pycodestyle::settings::Settings::default().into()),
pydocstyle: Some(pydocstyle::settings::Settings::default().into()),
pylint: Some(pylint::settings::Settings::default().into()),
pyupgrade: Some(pyupgrade::settings::Settings::default().into()),
})?)
}

Expand Down
24 changes: 0 additions & 24 deletions ruff.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f3ed25c

Please sign in to comment.