diff --git a/README.md b/README.md index d08d2e64f4a1f..3685509cbce17 100644 --- a/README.md +++ b/README.md @@ -2232,27 +2232,6 @@ target-version = "py37" --- -#### [`task-tags`](#task-tags) - -A list of task tags to recognize (e.g., "TODO", "FIXME", "XXX"). - -Comments starting with these tags will be ignored by commented-out code -detection (`ERA`), and skipped by line-length checks (`E501`) if -`ignore-overlong-task-comments` is set to `true`. - -**Default value**: `["TODO", "FIXME", "XXX"]` - -**Type**: `Vec` - -**Example usage**: - -```toml -[tool.ruff] -task-tags = ["HACK"] -``` - ---- - #### [`unfixable`](#unfixable) A list of check code prefixes to consider un-autofix-able. @@ -3036,27 +3015,6 @@ staticmethod-decorators = ["staticmethod", "stcmthd"] --- -### `pycodestyle` - -#### [`ignore-overlong-task-comments`](#ignore-overlong-task-comments) - -Whether or not line-length checks (`E501`) should be triggered for -comments starting with `task-tags` (by default: ["TODO", "FIXME", -and "XXX"]). - -**Default value**: `false` - -**Type**: `bool` - -**Example usage**: - -```toml -[tool.ruff.pycodestyle] -ignore-overlong-task-comments = true -``` - ---- - ### `pydocstyle` #### [`convention`](#convention) diff --git a/flake8_to_ruff/src/converter.rs b/flake8_to_ruff/src/converter.rs index a8c3913d1224c..11541998168b8 100644 --- a/flake8_to_ruff/src/converter.rs +++ b/flake8_to_ruff/src/converter.rs @@ -390,7 +390,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -404,7 +403,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }); @@ -453,7 +451,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -467,7 +464,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }); @@ -516,7 +512,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -530,7 +525,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }); @@ -579,7 +573,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -593,7 +586,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }); @@ -642,7 +634,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -661,7 +652,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }); @@ -714,7 +704,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -728,7 +717,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: Some(pydocstyle::settings::Options { convention: Some(Convention::Numpy), }), @@ -780,7 +768,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -799,7 +786,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }); diff --git a/resources/test/fixtures/pycodestyle/E501_1.py b/resources/test/fixtures/pycodestyle/E501_1.py deleted file mode 100644 index 6c9e62fa81a0d..0000000000000 --- a/resources/test/fixtures/pycodestyle/E501_1.py +++ /dev/null @@ -1,6 +0,0 @@ -# TODO: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -# TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -# TODO comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -# FIXME: comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -# FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -# FIXME comments starting with one of the configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` diff --git a/ruff.schema.json b/ruff.schema.json index 2b97da8dc75bb..fab5b52b0e6d3 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -299,17 +299,6 @@ } } }, - "pycodestyle": { - "description": "Options for the `pycodestyle` plugin.", - "anyOf": [ - { - "$ref": "#/definitions/Pycodestyle" - }, - { - "type": "null" - } - ] - }, "pydocstyle": { "description": "Options for the `pydocstyle` plugin.", "anyOf": [ @@ -388,16 +377,6 @@ } ] }, - "task-tags": { - "description": "A list of task tags to recognize (e.g., \"TODO\", \"FIXME\", \"XXX\").\n\nComments starting with these tags will be ignored by commented-out code detection (`ERA`), and skipped by line-length checks (`E501`) if `ignore-overlong-task-comments` is set to `true`.", - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, "unfixable": { "description": "A list of check code prefixes to consider un-autofix-able.", "type": [ @@ -1508,19 +1487,6 @@ }, "additionalProperties": false }, - "Pycodestyle": { - "type": "object", - "properties": { - "ignore-overlong-task-comments": { - "description": "Whether or not line-length checks (`E501`) should be triggered for comments starting with `task-tags` (by default: [\"TODO\", \"FIXME\", and \"XXX\"]).", - "type": [ - "boolean", - "null" - ] - } - }, - "additionalProperties": false - }, "Pydocstyle": { "type": "object", "properties": { diff --git a/src/checkers/lines.rs b/src/checkers/lines.rs index 6cd8d5397fa35..2d244ef932795 100644 --- a/src/checkers/lines.rs +++ b/src/checkers/lines.rs @@ -57,7 +57,7 @@ pub fn check_lines( } if enforce_line_too_long { - if let Some(check) = line_too_long(index, line, settings) { + if let Some(check) = line_too_long(index, line, settings.line_length) { checks.push(check); } } diff --git a/src/eradicate/checks.rs b/src/eradicate/checks.rs index a47604a769a23..5cefb29b3a6e8 100644 --- a/src/eradicate/checks.rs +++ b/src/eradicate/checks.rs @@ -31,7 +31,7 @@ pub fn commented_out_code( let line = locator.slice_source_code_range(&Range::new(location, end_location)); // Verify that the comment is on its own line, and that it contains code. - if is_standalone_comment(&line) && comment_contains_code(&line, &settings.task_tags[..]) { + if is_standalone_comment(&line) && comment_contains_code(&line) { let mut check = Check::new(CheckKind::CommentedOutCode, Range::new(start, end)); if matches!(autofix, flags::Autofix::Enabled) && settings.fixable.contains(&CheckCode::ERA001) diff --git a/src/eradicate/detection.rs b/src/eradicate/detection.rs index 68b996549e779..4d368f9800cad 100644 --- a/src/eradicate/detection.rs +++ b/src/eradicate/detection.rs @@ -4,7 +4,7 @@ use regex::Regex; static ALLOWLIST_REGEX: Lazy = Lazy::new(|| { Regex::new( - r"^(?i)(?:pylint|pyright|noqa|nosec|type:\s*ignore|fmt:\s*(on|off)|isort:\s*(on|off|skip|skip_file|split|dont-add-imports(:\s*\[.*?])?))" + r"^(?i)(?:pylint|pyright|noqa|nosec|type:\s*ignore|fmt:\s*(on|off)|isort:\s*(on|off|skip|skip_file|split|dont-add-imports(:\s*\[.*?])?)|TODO|FIXME|XXX)" ).unwrap() }); static BRACKET_REGEX: Lazy = Lazy::new(|| Regex::new(r"^[()\[\]{}\s]+$").unwrap()); @@ -30,7 +30,7 @@ static PARTIAL_DICTIONARY_REGEX: Lazy = static PRINT_RETURN_REGEX: Lazy = Lazy::new(|| Regex::new(r"^(print|return)\b\s*").unwrap()); /// Returns `true` if a comment contains Python code. -pub fn comment_contains_code(line: &str, task_tags: &[String]) -> bool { +pub fn comment_contains_code(line: &str) -> bool { let line = if let Some(line) = line.trim().strip_prefix('#') { line.trim() } else { @@ -47,12 +47,6 @@ pub fn comment_contains_code(line: &str, task_tags: &[String]) -> bool { return false; } - if let Some(first) = line.split(&[' ', ':']).next() { - if task_tags.iter().any(|tag| tag == first) { - return false; - } - } - if CODING_COMMENT_REGEX.is_match(line) { return false; } @@ -103,166 +97,142 @@ mod tests { #[test] fn comment_contains_code_basic() { - assert!(comment_contains_code("# x = 1", &[])); - assert!(comment_contains_code("#from foo import eradicate", &[])); - assert!(comment_contains_code("#import eradicate", &[])); - assert!(comment_contains_code(r#"#"key": value,"#, &[])); - assert!(comment_contains_code(r#"#"key": "value","#, &[])); - assert!(comment_contains_code(r#"#"key": 1 + 1,"#, &[])); - assert!(comment_contains_code("#'key': 1 + 1,", &[])); - assert!(comment_contains_code(r#"#"key": {"#, &[])); - assert!(comment_contains_code("#}", &[])); - assert!(comment_contains_code("#} )]", &[])); - - assert!(!comment_contains_code("#", &[])); - assert!(!comment_contains_code("# This is a (real) comment.", &[])); - assert!(!comment_contains_code("# 123", &[])); - assert!(!comment_contains_code("# 123.1", &[])); - assert!(!comment_contains_code("# 1, 2, 3", &[])); - assert!(!comment_contains_code("x = 1 # x = 1", &[])); - assert!(!comment_contains_code( - "# pylint: disable=redefined-outer-name", - &[] - ),); + assert!(comment_contains_code("# x = 1")); + assert!(comment_contains_code("#from foo import eradicate")); + assert!(comment_contains_code("#import eradicate")); + assert!(comment_contains_code(r#"#"key": value,"#)); + assert!(comment_contains_code(r#"#"key": "value","#)); + assert!(comment_contains_code(r#"#"key": 1 + 1,"#)); + assert!(comment_contains_code("#'key': 1 + 1,")); + assert!(comment_contains_code(r#"#"key": {"#)); + assert!(comment_contains_code("#}")); + assert!(comment_contains_code("#} )]")); + + assert!(!comment_contains_code("#")); + assert!(!comment_contains_code("# This is a (real) comment.")); + assert!(!comment_contains_code("# 123")); + assert!(!comment_contains_code("# 123.1")); + assert!(!comment_contains_code("# 1, 2, 3")); + assert!(!comment_contains_code("x = 1 # x = 1")); assert!(!comment_contains_code( - "# Issue #999: This is not code", - &[] + "# pylint: disable=redefined-outer-name" )); + assert!(!comment_contains_code("# Issue #999: This is not code")); // TODO(charlie): This should be `true` under aggressive mode. - assert!(!comment_contains_code("#},", &[])); + assert!(!comment_contains_code("#},")); } #[test] fn comment_contains_code_with_print() { - assert!(comment_contains_code("#print", &[])); - assert!(comment_contains_code("#print(1)", &[])); - assert!(comment_contains_code("#print 1", &[])); + assert!(comment_contains_code("#print")); + assert!(comment_contains_code("#print(1)")); + assert!(comment_contains_code("#print 1")); - assert!(!comment_contains_code("#to print", &[])); + assert!(!comment_contains_code("#to print")); } #[test] fn comment_contains_code_with_return() { - assert!(comment_contains_code("#return x", &[])); + assert!(comment_contains_code("#return x")); - assert!(!comment_contains_code("#to print", &[])); + assert!(!comment_contains_code("#to print")); } #[test] fn comment_contains_code_with_multiline() { - assert!(comment_contains_code("#else:", &[])); - assert!(comment_contains_code("# else : ", &[])); - assert!(comment_contains_code(r#"# "foo %d" % \\"#, &[])); - assert!(comment_contains_code("#elif True:", &[])); - assert!(comment_contains_code("#x = foo(", &[])); - assert!(comment_contains_code("#except Exception:", &[])); - - assert!(!comment_contains_code("# this is = to that :(", &[])); - assert!(!comment_contains_code("#else", &[])); - assert!(!comment_contains_code("#or else:", &[])); - assert!(!comment_contains_code("#else True:", &[])); + assert!(comment_contains_code("#else:")); + assert!(comment_contains_code("# else : ")); + assert!(comment_contains_code(r#"# "foo %d" % \\"#)); + assert!(comment_contains_code("#elif True:")); + assert!(comment_contains_code("#x = foo(")); + assert!(comment_contains_code("#except Exception:")); + + assert!(!comment_contains_code("# this is = to that :(")); + assert!(!comment_contains_code("#else")); + assert!(!comment_contains_code("#or else:")); + assert!(!comment_contains_code("#else True:")); // Unpacking assignments assert!(comment_contains_code( - "# user_content_type, _ = TimelineEvent.objects.using(db_alias).get_or_create(", - &[] - ),); + "# user_content_type, _ = TimelineEvent.objects.using(db_alias).get_or_create(" + )); assert!(comment_contains_code( - "# (user_content_type, _) = TimelineEvent.objects.using(db_alias).get_or_create(", - &[] - ),); + "# (user_content_type, _) = TimelineEvent.objects.using(db_alias).get_or_create(" + )); assert!(comment_contains_code( - "# ( user_content_type , _ )= TimelineEvent.objects.using(db_alias).get_or_create(", - &[] + "# ( user_content_type , _ )= TimelineEvent.objects.using(db_alias).get_or_create(" )); assert!(comment_contains_code( - "# app_label=\"core\", model=\"user\"", - &[] + "# app_label=\"core\", model=\"user\"" )); - assert!(comment_contains_code("# )", &[])); + assert!(comment_contains_code("# )")); // TODO(charlie): This should be `true` under aggressive mode. - assert!(!comment_contains_code("#def foo():", &[])); + assert!(!comment_contains_code("#def foo():")); } #[test] fn comment_contains_code_with_sentences() { - assert!(!comment_contains_code("#code is good", &[])); + assert!(!comment_contains_code("#code is good")); } #[test] fn comment_contains_code_with_encoding() { - assert!(comment_contains_code("# codings=utf-8", &[])); + assert!(comment_contains_code("# codings=utf-8")); - assert!(!comment_contains_code("# coding=utf-8", &[])); - assert!(!comment_contains_code("#coding= utf-8", &[])); - assert!(!comment_contains_code("# coding: utf-8", &[])); - assert!(!comment_contains_code("# encoding: utf8", &[])); + assert!(!comment_contains_code("# coding=utf-8")); + assert!(!comment_contains_code("#coding= utf-8")); + assert!(!comment_contains_code("# coding: utf-8")); + assert!(!comment_contains_code("# encoding: utf8")); } #[test] fn comment_contains_code_with_default_allowlist() { - assert!(!comment_contains_code("# pylint: disable=A0123", &[])); - assert!(!comment_contains_code("# pylint:disable=A0123", &[])); - assert!(!comment_contains_code("# pylint: disable = A0123", &[])); - assert!(!comment_contains_code("# pylint:disable = A0123", &[])); - assert!(!comment_contains_code( - "# pyright: reportErrorName=true", - &[] - )); - assert!(!comment_contains_code("# noqa", &[])); - assert!(!comment_contains_code("# NOQA", &[])); - assert!(!comment_contains_code("# noqa: A123", &[])); - assert!(!comment_contains_code("# noqa:A123", &[])); - assert!(!comment_contains_code("# nosec", &[])); - assert!(!comment_contains_code("# fmt: on", &[])); - assert!(!comment_contains_code("# fmt: off", &[])); - assert!(!comment_contains_code("# fmt:on", &[])); - assert!(!comment_contains_code("# fmt:off", &[])); - assert!(!comment_contains_code("# isort: on", &[])); - assert!(!comment_contains_code("# isort:on", &[])); - assert!(!comment_contains_code("# isort: off", &[])); - assert!(!comment_contains_code("# isort:off", &[])); - assert!(!comment_contains_code("# isort: skip", &[])); - assert!(!comment_contains_code("# isort:skip", &[])); - assert!(!comment_contains_code("# isort: skip_file", &[])); - assert!(!comment_contains_code("# isort:skip_file", &[])); - assert!(!comment_contains_code("# isort: split", &[])); - assert!(!comment_contains_code("# isort:split", &[])); - assert!(!comment_contains_code("# isort: dont-add-imports", &[])); - assert!(!comment_contains_code("# isort:dont-add-imports", &[])); - assert!(!comment_contains_code( - "# isort: dont-add-imports: [\"import os\"]", - &[] - )); - assert!(!comment_contains_code( - "# isort:dont-add-imports: [\"import os\"]", - &[] - )); - assert!(!comment_contains_code( - "# isort: dont-add-imports:[\"import os\"]", - &[] - )); + assert!(!comment_contains_code("# pylint: disable=A0123")); + assert!(!comment_contains_code("# pylint:disable=A0123")); + assert!(!comment_contains_code("# pylint: disable = A0123")); + assert!(!comment_contains_code("# pylint:disable = A0123")); + assert!(!comment_contains_code("# pyright: reportErrorName=true")); + assert!(!comment_contains_code("# noqa")); + assert!(!comment_contains_code("# NOQA")); + assert!(!comment_contains_code("# noqa: A123")); + assert!(!comment_contains_code("# noqa:A123")); + assert!(!comment_contains_code("# nosec")); + assert!(!comment_contains_code("# fmt: on")); + assert!(!comment_contains_code("# fmt: off")); + assert!(!comment_contains_code("# fmt:on")); + assert!(!comment_contains_code("# fmt:off")); + assert!(!comment_contains_code("# isort: on")); + assert!(!comment_contains_code("# isort:on")); + assert!(!comment_contains_code("# isort: off")); + assert!(!comment_contains_code("# isort:off")); + assert!(!comment_contains_code("# isort: skip")); + assert!(!comment_contains_code("# isort:skip")); + assert!(!comment_contains_code("# isort: skip_file")); + assert!(!comment_contains_code("# isort:skip_file")); + assert!(!comment_contains_code("# isort: split")); + assert!(!comment_contains_code("# isort:split")); + assert!(!comment_contains_code("# isort: dont-add-imports")); + assert!(!comment_contains_code("# isort:dont-add-imports")); assert!(!comment_contains_code( - "# isort:dont-add-imports:[\"import os\"]", - &[] + "# isort: dont-add-imports: [\"import os\"]" )); - assert!(!comment_contains_code("# type: ignore", &[])); - assert!(!comment_contains_code("# type:ignore", &[])); - assert!(!comment_contains_code("# type: ignore[import]", &[])); - assert!(!comment_contains_code("# type:ignore[import]", &[])); assert!(!comment_contains_code( - "# TODO: Do that", - &["TODO".to_string()] + "# isort:dont-add-imports: [\"import os\"]" )); assert!(!comment_contains_code( - "# FIXME: Fix that", - &["FIXME".to_string()] + "# isort: dont-add-imports:[\"import os\"]" )); assert!(!comment_contains_code( - "# XXX: What ever", - &["XXX".to_string()] + "# isort:dont-add-imports:[\"import os\"]" )); + assert!(!comment_contains_code("# type: ignore")); + assert!(!comment_contains_code("# type:ignore")); + assert!(!comment_contains_code("# type: ignore[import]")); + assert!(!comment_contains_code("# type:ignore[import]")); + assert!(!comment_contains_code("# TODO: Do that")); + assert!(!comment_contains_code("# FIXME: Fix that")); + assert!(!comment_contains_code("# XXX: What ever")); } } diff --git a/src/lib_wasm.rs b/src/lib_wasm.rs index bf9257f926714..30a0eabe5fa80 100644 --- a/src/lib_wasm.rs +++ b/src/lib_wasm.rs @@ -18,7 +18,7 @@ use crate::source_code_style::SourceCodeStyleDetector; use crate::{ directives, flake8_annotations, flake8_bandit, flake8_bugbear, flake8_errmsg, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_tidy_imports, - flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyupgrade, + flake8_unused_arguments, isort, mccabe, pep8_naming, pydocstyle, pyupgrade, }; const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -112,7 +112,6 @@ pub fn defaultSettings() -> Result { show_source: None, src: None, unfixable: None, - task_tags: None, update_check: None, // Use default options for all plugins. flake8_annotations: Some(flake8_annotations::settings::Settings::default().into()), @@ -131,7 +130,6 @@ pub fn defaultSettings() -> Result { isort: Some(isort::settings::Settings::default().into()), mccabe: Some(mccabe::settings::Settings::default().into()), pep8_naming: Some(pep8_naming::settings::Settings::default().into()), - pycodestyle: Some(pycodestyle::settings::Settings::default().into()), pydocstyle: Some(pydocstyle::settings::Settings::default().into()), pyupgrade: Some(pyupgrade::settings::Settings::default().into()), })?) diff --git a/src/pycodestyle/checks.rs b/src/pycodestyle/checks.rs index d62dc13879b28..c4f5f893367be 100644 --- a/src/pycodestyle/checks.rs +++ b/src/pycodestyle/checks.rs @@ -8,44 +8,34 @@ use crate::ast::helpers::except_range; use crate::ast::types::Range; use crate::autofix::Fix; use crate::registry::{Check, CheckKind}; -use crate::settings::Settings; use crate::source_code_locator::SourceCodeLocator; static URL_REGEX: Lazy = Lazy::new(|| Regex::new(r"^https?://\S+$").unwrap()); /// E501 -pub fn line_too_long(lineno: usize, line: &str, settings: &Settings) -> Option { +pub fn line_too_long(lineno: usize, line: &str, max_line_length: usize) -> Option { let line_length = line.chars().count(); - if line_length <= settings.line_length { + if line_length <= max_line_length { return None; } let mut chunks = line.split_whitespace(); - let (Some(first), Some(second)) = (chunks.next(), chunks.next()) else { + let (Some(first), Some(_)) = (chunks.next(), chunks.next()) else { // Single word / no printable chars - no way to make the line shorter return None; }; - if first == "#" { - if settings.pycodestyle.ignore_overlong_task_comments { - let second = second.trim_end_matches(':'); - if settings.task_tags.iter().any(|tag| tag == second) { - return None; - } - } - - // Do not enforce the line length for commented lines that end with a URL - // or contain only a single word. - if chunks.last().map_or(true, |c| URL_REGEX.is_match(c)) { - return None; - } + // Do not enforce the line length for commented lines that end with a URL + // or contain only a single word. + if first == "#" && chunks.last().map_or(true, |c| URL_REGEX.is_match(c)) { + return None; } Some(Check::new( - CheckKind::LineTooLong(line_length, settings.line_length), + CheckKind::LineTooLong(line_length, max_line_length), Range::new( - Location::new(lineno + 1, settings.line_length), + Location::new(lineno + 1, max_line_length), Location::new(lineno + 1, line_length), ), )) diff --git a/src/pycodestyle/mod.rs b/src/pycodestyle/mod.rs index 49ee8db613090..8027c14f3950e 100644 --- a/src/pycodestyle/mod.rs +++ b/src/pycodestyle/mod.rs @@ -1,6 +1,5 @@ pub mod checks; pub mod plugins; -pub mod settings; #[cfg(test)] mod tests { @@ -10,7 +9,6 @@ mod tests { use anyhow::Result; use test_case::test_case; - use super::settings::Settings; use crate::linter::test_path; use crate::registry::CheckCode; use crate::settings; @@ -58,21 +56,4 @@ mod tests { insta::assert_yaml_snapshot!(checks); Ok(()) } - - #[test_case(false)] - #[test_case(true)] - fn task_tags(ignore_overlong_task_comments: bool) -> Result<()> { - let snapshot = format!("task_tags_{ignore_overlong_task_comments}"); - let checks = test_path( - Path::new("./resources/test/fixtures/pycodestyle/E501_1.py"), - &settings::Settings { - pycodestyle: Settings { - ignore_overlong_task_comments, - }, - ..settings::Settings::for_rule(CheckCode::E501) - }, - )?; - insta::assert_yaml_snapshot!(snapshot, checks); - Ok(()) - } } diff --git a/src/pycodestyle/settings.rs b/src/pycodestyle/settings.rs deleted file mode 100644 index a64e1e4426c8b..0000000000000 --- a/src/pycodestyle/settings.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! Settings for the `pycodestyle` plugin. - -use ruff_macros::ConfigurationOptions; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive( - Debug, PartialEq, Eq, Serialize, Deserialize, Default, ConfigurationOptions, JsonSchema, -)] -#[serde(deny_unknown_fields, rename_all = "kebab-case", rename = "Pycodestyle")] -pub struct Options { - #[option( - default = "false", - value_type = "bool", - example = r#" - ignore-overlong-task-comments = true - "# - )] - /// Whether or not line-length checks (`E501`) should be triggered for - /// comments starting with `task-tags` (by default: ["TODO", "FIXME", - /// and "XXX"]). - pub ignore_overlong_task_comments: Option, -} - -#[derive(Debug, Default, Hash)] -pub struct Settings { - pub ignore_overlong_task_comments: bool, -} - -impl From for Settings { - fn from(options: Options) -> Self { - Self { - ignore_overlong_task_comments: options - .ignore_overlong_task_comments - .unwrap_or_default(), - } - } -} - -impl From for Options { - fn from(settings: Settings) -> Self { - Self { - ignore_overlong_task_comments: Some(settings.ignore_overlong_task_comments), - } - } -} diff --git a/src/pycodestyle/snapshots/ruff__pycodestyle__tests__task_tags_false.snap b/src/pycodestyle/snapshots/ruff__pycodestyle__tests__task_tags_false.snap deleted file mode 100644 index 050ba2dede7ce..0000000000000 --- a/src/pycodestyle/snapshots/ruff__pycodestyle__tests__task_tags_false.snap +++ /dev/null @@ -1,77 +0,0 @@ ---- -source: src/pycodestyle/mod.rs -expression: checks ---- -- kind: - LineTooLong: - - 149 - - 88 - location: - row: 1 - column: 88 - end_location: - row: 1 - column: 149 - fix: ~ - parent: ~ -- kind: - LineTooLong: - - 148 - - 88 - location: - row: 2 - column: 88 - end_location: - row: 2 - column: 148 - fix: ~ - parent: ~ -- kind: - LineTooLong: - - 155 - - 88 - location: - row: 3 - column: 88 - end_location: - row: 3 - column: 155 - fix: ~ - parent: ~ -- kind: - LineTooLong: - - 150 - - 88 - location: - row: 4 - column: 88 - end_location: - row: 4 - column: 150 - fix: ~ - parent: ~ -- kind: - LineTooLong: - - 149 - - 88 - location: - row: 5 - column: 88 - end_location: - row: 5 - column: 149 - fix: ~ - parent: ~ -- kind: - LineTooLong: - - 156 - - 88 - location: - row: 6 - column: 88 - end_location: - row: 6 - column: 156 - fix: ~ - parent: ~ - diff --git a/src/pycodestyle/snapshots/ruff__pycodestyle__tests__task_tags_true.snap b/src/pycodestyle/snapshots/ruff__pycodestyle__tests__task_tags_true.snap deleted file mode 100644 index 803588cfbe0fc..0000000000000 --- a/src/pycodestyle/snapshots/ruff__pycodestyle__tests__task_tags_true.snap +++ /dev/null @@ -1,6 +0,0 @@ ---- -source: src/pycodestyle/mod.rs -expression: checks ---- -[] - diff --git a/src/settings/configuration.rs b/src/settings/configuration.rs index e6464b3a79796..077b119035c3b 100644 --- a/src/settings/configuration.rs +++ b/src/settings/configuration.rs @@ -22,7 +22,7 @@ use crate::settings::types::{ use crate::{ flake8_annotations, flake8_bandit, flake8_bugbear, flake8_errmsg, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_tidy_imports, flake8_unused_arguments, fs, isort, - mccabe, pep8_naming, pycodestyle, pydocstyle, pyupgrade, + mccabe, pep8_naming, pydocstyle, pyupgrade, }; #[derive(Debug, Default)] @@ -52,7 +52,6 @@ pub struct Configuration { pub src: Option>, pub target_version: Option, pub unfixable: Option>, - pub task_tags: Option>, pub update_check: Option, // Plugins pub flake8_annotations: Option, @@ -67,7 +66,6 @@ pub struct Configuration { pub isort: Option, pub mccabe: Option, pub pep8_naming: Option, - pub pycodestyle: Option, pub pydocstyle: Option, pub pyupgrade: Option, } @@ -152,7 +150,6 @@ impl Configuration { .transpose()?, target_version: options.target_version, unfixable: options.unfixable, - task_tags: options.task_tags, update_check: options.update_check, // Plugins flake8_annotations: options.flake8_annotations, @@ -167,7 +164,6 @@ impl Configuration { isort: options.isort, mccabe: options.mccabe, pep8_naming: options.pep8_naming, - pycodestyle: options.pycodestyle, pydocstyle: options.pydocstyle, pyupgrade: options.pyupgrade, }) @@ -215,7 +211,6 @@ impl Configuration { src: self.src.or(config.src), target_version: self.target_version.or(config.target_version), unfixable: self.unfixable.or(config.unfixable), - task_tags: self.task_tags.or(config.task_tags), update_check: self.update_check.or(config.update_check), // Plugins flake8_annotations: self.flake8_annotations.or(config.flake8_annotations), @@ -234,7 +229,6 @@ impl Configuration { isort: self.isort.or(config.isort), mccabe: self.mccabe.or(config.mccabe), pep8_naming: self.pep8_naming.or(config.pep8_naming), - pycodestyle: self.pycodestyle.or(config.pycodestyle), pydocstyle: self.pydocstyle.or(config.pydocstyle), pyupgrade: self.pyupgrade.or(config.pyupgrade), } diff --git a/src/settings/mod.rs b/src/settings/mod.rs index f44e0f4c66405..bb37d4a84fadf 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -26,7 +26,7 @@ use crate::settings::types::{ use crate::{ flake8_annotations, flake8_bandit, flake8_bugbear, flake8_errmsg, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_tidy_imports, flake8_unused_arguments, isort, - mccabe, one_time_warning, pep8_naming, pycodestyle, pydocstyle, pyupgrade, + mccabe, one_time_warning, pep8_naming, pydocstyle, pyupgrade, }; pub mod configuration; @@ -60,7 +60,6 @@ pub struct Settings { pub show_source: bool, pub src: Vec, pub target_version: PythonVersion, - pub task_tags: Vec, pub update_check: bool, // Plugins pub flake8_annotations: flake8_annotations::settings::Settings, @@ -75,7 +74,6 @@ pub struct Settings { pub isort: isort::settings::Settings, pub mccabe: mccabe::settings::Settings, pub pep8_naming: pep8_naming::settings::Settings, - pub pycodestyle: pycodestyle::settings::Settings, pub pydocstyle: pydocstyle::settings::Settings, pub pyupgrade: pyupgrade::settings::Settings, } @@ -176,9 +174,6 @@ impl Settings { .src .unwrap_or_else(|| vec![project_root.to_path_buf()]), target_version: config.target_version.unwrap_or_default(), - task_tags: config.task_tags.unwrap_or_else(|| { - vec!["TODO".to_string(), "FIXME".to_string(), "XXX".to_string()] - }), update_check: config.update_check.unwrap_or(true), // Plugins flake8_annotations: config @@ -229,10 +224,6 @@ impl Settings { .pep8_naming .map(std::convert::Into::into) .unwrap_or_default(), - pycodestyle: config - .pycodestyle - .map(std::convert::Into::into) - .unwrap_or_default(), pydocstyle: config .pydocstyle .map(std::convert::Into::into) @@ -266,7 +257,6 @@ impl Settings { show_source: false, src: vec![path_dedot::CWD.clone()], target_version: PythonVersion::Py310, - task_tags: vec!["TODO".to_string(), "FIXME".to_string()], update_check: false, flake8_annotations: flake8_annotations::settings::Settings::default(), flake8_bandit: flake8_bandit::settings::Settings::default(), @@ -280,7 +270,6 @@ impl Settings { isort: isort::settings::Settings::default(), mccabe: mccabe::settings::Settings::default(), pep8_naming: pep8_naming::settings::Settings::default(), - pycodestyle: pycodestyle::settings::Settings::default(), pydocstyle: pydocstyle::settings::Settings::default(), pyupgrade: pyupgrade::settings::Settings::default(), } @@ -308,7 +297,6 @@ impl Settings { show_source: false, src: vec![path_dedot::CWD.clone()], target_version: PythonVersion::Py310, - task_tags: vec!["TODO".to_string()], update_check: false, flake8_annotations: flake8_annotations::settings::Settings::default(), flake8_bandit: flake8_bandit::settings::Settings::default(), @@ -322,7 +310,6 @@ impl Settings { isort: isort::settings::Settings::default(), mccabe: mccabe::settings::Settings::default(), pep8_naming: pep8_naming::settings::Settings::default(), - pycodestyle: pycodestyle::settings::Settings::default(), pydocstyle: pydocstyle::settings::Settings::default(), pyupgrade: pyupgrade::settings::Settings::default(), } diff --git a/src/settings/options.rs b/src/settings/options.rs index 2a64ce1564a14..1bf3e5761f780 100644 --- a/src/settings/options.rs +++ b/src/settings/options.rs @@ -10,7 +10,7 @@ use crate::settings::types::{PythonVersion, SerializationFormat, Version}; use crate::{ flake8_annotations, flake8_bandit, flake8_bugbear, flake8_errmsg, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_tidy_imports, flake8_unused_arguments, isort, - mccabe, pep8_naming, pycodestyle, pydocstyle, pyupgrade, + mccabe, pep8_naming, pydocstyle, pyupgrade, }; #[derive( @@ -339,17 +339,6 @@ pub struct Options { )] /// A list of check code prefixes to consider un-autofix-able. pub unfixable: Option>, - #[option( - default = r#"["TODO", "FIXME", "XXX"]"#, - value_type = "Vec", - example = r#"task-tags = ["HACK"]"# - )] - /// A list of task tags to recognize (e.g., "TODO", "FIXME", "XXX"). - /// - /// Comments starting with these tags will be ignored by commented-out code - /// detection (`ERA`), and skipped by line-length checks (`E501`) if - /// `ignore-overlong-task-comments` is set to `true`. - pub task_tags: Option>, #[option( default = "true", value_type = "bool", @@ -395,9 +384,6 @@ pub struct Options { /// Options for the `pep8-naming` plugin. pub pep8_naming: Option, #[option_group] - /// Options for the `pycodestyle` plugin. - pub pycodestyle: Option, - #[option_group] /// Options for the `pydocstyle` plugin. pub pydocstyle: Option, #[option_group] diff --git a/src/settings/pyproject.rs b/src/settings/pyproject.rs index d6c0b70a4693c..1cec9e73f49fc 100644 --- a/src/settings/pyproject.rs +++ b/src/settings/pyproject.rs @@ -188,7 +188,6 @@ mod tests { src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -202,7 +201,6 @@ mod tests { isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }) @@ -244,7 +242,6 @@ line-length = 79 src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, cache_dir: None, flake8_annotations: None, @@ -259,7 +256,6 @@ line-length = 79 isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }) @@ -302,7 +298,6 @@ exclude = ["foo.py"] src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -316,7 +311,6 @@ exclude = ["foo.py"] isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }) @@ -359,7 +353,6 @@ select = ["E501"] src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -373,7 +366,6 @@ select = ["E501"] isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }) @@ -417,7 +409,6 @@ ignore = ["E501"] src: None, target_version: None, unfixable: None, - task_tags: None, update_check: None, flake8_annotations: None, flake8_bandit: None, @@ -431,7 +422,6 @@ ignore = ["E501"] isort: None, mccabe: None, pep8_naming: None, - pycodestyle: None, pydocstyle: None, pyupgrade: None, }) @@ -505,7 +495,6 @@ other-attribute = 1 format: None, force_exclude: None, unfixable: None, - task_tags: None, update_check: None, cache_dir: None, per_file_ignores: Some(FxHashMap::from_iter([( @@ -609,7 +598,6 @@ other-attribute = 1 ]), staticmethod_decorators: Some(vec!["staticmethod".to_string()]), }), - pycodestyle: None, pydocstyle: None, pyupgrade: None, }