diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1f15e38f..5c11f1fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,7 @@ ## Pre-commit install -We use [pre-commit](https://pre-commit.com/) to run some quick linting such as `black`. -While pre-commit isn't configured in CI, `black` is. `pylint` and running tests are not configured -for pre-commit so commiting is fast. +We use [pre-commit](https://pre-commit.com/) to run some quick linting such as `black` and `ruff`. ## Local Development @@ -19,7 +17,7 @@ to specify a specific Python version. If using `bash` or any compatible shell, a 1. Run `pip install ".[all]"` to install packages used for development and testing -1. You should now be able to run `pylint`, `pytest`, etc. +1. You should now be able to run `ruff`, `pytest`, etc. ## Docker diff --git a/integration_tests/base_test.py b/integration_tests/base_test.py index ac79cce3..ddbc5811 100644 --- a/integration_tests/base_test.py +++ b/integration_tests/base_test.py @@ -1,4 +1,3 @@ -# pylint: disable=no-member, protected-access, attribute-defined-outside-init import git import json import os diff --git a/src/codemodder/codemods/base_visitor.py b/src/codemodder/codemods/base_visitor.py index cb0bbb26..2009688c 100644 --- a/src/codemodder/codemods/base_visitor.py +++ b/src/codemodder/codemods/base_visitor.py @@ -15,7 +15,7 @@ def __init__( results: list[Result] | None, line_exclude: list[int], line_include: list[int], - ): # pylint: disable=super-init-not-called + ): self.results = results self.line_exclude = line_exclude self.line_include = line_include diff --git a/src/codemodder/codemods/libcst_transformer.py b/src/codemodder/codemods/libcst_transformer.py index c53ffa74..de1ab794 100644 --- a/src/codemodder/codemods/libcst_transformer.py +++ b/src/codemodder/codemods/libcst_transformer.py @@ -29,9 +29,7 @@ def update_code(file_path, new_code): f.write(new_code) -class LibcstResultTransformer( - BaseTransformer -): # pylint: disable=too-many-public-methods +class LibcstResultTransformer(BaseTransformer): """ Transformer class that performs libcst-based transformations on a given file @@ -76,7 +74,6 @@ def transform( def _new_or_updated_node(self, original_node, updated_node): if self.node_is_selected(original_node): if (attr := getattr(self, "on_result_found", None)) is not None: - # pylint: disable=not-callable new_node = attr(original_node, updated_node) self.report_change(original_node) return new_node @@ -102,7 +99,6 @@ def leave_ClassDef( return self._new_or_updated_node(original_node, updated_node) def node_position(self, node): - # pylint: disable=no-member # See https://github.com/Instagram/LibCST/blob/main/libcst/_metadata_dependent.py#L112 return self.get_metadata(self.METADATA_DEPENDENCIES[0], node) @@ -134,14 +130,11 @@ def report_change(self, original_node): ) def remove_unused_import(self, original_node): - # pylint: disable=no-member RemoveImportsVisitor.remove_unused_import_by_node(self.context, original_node) def add_needed_import(self, module, obj=None): # TODO: do we need to check if this import already exists? - AddImportsVisitor.add_needed_import( - self.context, module, obj # pylint: disable=no-member - ) + AddImportsVisitor.add_needed_import(self.context, module, obj) def update_call_target( self, diff --git a/src/codemodder/codemods/sonar.py b/src/codemodder/codemods/sonar.py index 8870ec4a..a1733b97 100644 --- a/src/codemodder/codemods/sonar.py +++ b/src/codemodder/codemods/sonar.py @@ -21,12 +21,12 @@ def from_core_codemod( rules: list[str], transformer: BaseTransformerPipeline | None = None, new_references: list[Reference] | None = None, - ): # pylint: disable=too-many-arguments + ): return SonarCodemod( metadata=Metadata( name=name, summary="Sonar: " + other.summary, - review_guidance=other._metadata.review_guidance, # pylint: disable=protected-access + review_guidance=other._metadata.review_guidance, references=( other.references if not new_references diff --git a/src/codemodder/codemods/utils.py b/src/codemodder/codemods/utils.py index 3538121b..30519523 100644 --- a/src/codemodder/codemods/utils.py +++ b/src/codemodder/codemods/utils.py @@ -22,7 +22,6 @@ class BaseType(Enum): FALSE = 7 -# pylint: disable-next=R0911 def infer_expression_type(node: cst.BaseExpression) -> Optional[BaseType]: """ Tries to infer if the resulting type of a given expression is one of the base literal types. diff --git a/src/codemodder/context.py b/src/codemodder/context.py index 6e3ee813..080b9f58 100644 --- a/src/codemodder/context.py +++ b/src/codemodder/context.py @@ -50,7 +50,7 @@ def __init__( path_exclude: list[str], tool_result_files_map: dict[str, list[str]] | None = None, max_workers: int = 1, - ): # pylint: disable=too-many-arguments + ): self.directory = directory self.dry_run = dry_run self.verbose = verbose @@ -118,7 +118,6 @@ def process_dependencies( self._dependency_update_by_codemod[codemod_id] = None return record - # pylint: disable-next=cyclic-import from codemodder.dependency_management import DependencyManager for package_store in store_list: diff --git a/src/codemodder/result.py b/src/codemodder/result.py index dcc84b38..7e38f43d 100644 --- a/src/codemodder/result.py +++ b/src/codemodder/result.py @@ -24,7 +24,7 @@ class Result(ABCDataclass): rule_id: str locations: list[Location] - def match_location(self, pos, node): # pylint: disable=unused-argument + def match_location(self, pos, node): for location in self.locations: start_column = location.start.column end_column = location.end.column diff --git a/src/core_codemods/file_resource_leak.py b/src/core_codemods/file_resource_leak.py index a89543c5..1879cc3d 100644 --- a/src/core_codemods/file_resource_leak.py +++ b/src/core_codemods/file_resource_leak.py @@ -191,9 +191,7 @@ def __init__( self.leaked_assigned_resources = leaked_assigned_resources self.changes: list[Change] = [] - def _is_fixable( - self, block, index, named_targets, other_targets - ) -> bool: # pylint: disable=too-many-arguments + def _is_fixable(self, block, index, named_targets, other_targets) -> bool: # assigned to something that is not a Name? if other_targets: return False @@ -363,7 +361,6 @@ def _find_transitive_assignment_targets( return named_targets, other_targets return ([], []) - # pylint: disable-next=too-many-arguments def _wrap_in_with_statement( self, stmts: list[SimpleStatementLine], diff --git a/src/core_codemods/fix_async_task_instantiation.py b/src/core_codemods/fix_async_task_instantiation.py index b7f5e486..65a6fac5 100644 --- a/src/core_codemods/fix_async_task_instantiation.py +++ b/src/core_codemods/fix_async_task_instantiation.py @@ -20,7 +20,6 @@ class FixAsyncTaskInstantiation(SimpleCodemod, NameAndAncestorResolutionMixin): change_description = "Replace instantiation of `asyncio.Task` with higher-level functions to create tasks." _module_name = "asyncio" - # pylint: disable=too-many-return-statements def leave_Call(self, original_node: cst.Call, updated_node: cst.Call) -> cst.Call: if not self.filter_by_path_includes_or_excludes( self.node_position(original_node) diff --git a/src/core_codemods/flask_json_response_type.py b/src/core_codemods/flask_json_response_type.py index 7e1b5aa0..9af6a038 100644 --- a/src/core_codemods/flask_json_response_type.py +++ b/src/core_codemods/flask_json_response_type.py @@ -44,7 +44,7 @@ class FlaskJsonResponseTypeVisitor( content_type_key = "Content-Type" json_content_type = "application/json" - def __init__( # pylint: disable=super-init-not-called + def __init__( self, context: CodemodContext, file_context: FileContext, diff --git a/src/core_codemods/sql_parameterization.py b/src/core_codemods/sql_parameterization.py index 474e2753..d88146aa 100644 --- a/src/core_codemods/sql_parameterization.py +++ b/src/core_codemods/sql_parameterization.py @@ -222,7 +222,6 @@ def _fix_injection( return (prepend, append) - # pylint: disable-next=too-many-arguments def _remove_literal_and_gather_extra( self, original_node, updated_node, prefix, new_raw_value, extra_raw_value ) -> Optional[SimpleString]: diff --git a/src/core_codemods/url_sandbox.py b/src/core_codemods/url_sandbox.py index 718bedf4..60190bc9 100644 --- a/src/core_codemods/url_sandbox.py +++ b/src/core_codemods/url_sandbox.py @@ -165,7 +165,6 @@ def _find_assignments(self, node: CSTNode): Given a MetadataWrapper and a CSTNode representing an access, find all the possible assignments that it refers. """ scope = self.get_metadata(ScopeProvider, node) - # pylint: disable=protected-access return next(iter(scope.accesses[node]))._Access__assignments def find_single_assignment(self, node: CSTNode) -> Optional[CSTNode]: diff --git a/tests/codemods/base_codemod_test.py b/tests/codemods/base_codemod_test.py index 9de8f263..001e8460 100644 --- a/tests/codemods/base_codemod_test.py +++ b/tests/codemods/base_codemod_test.py @@ -1,4 +1,3 @@ -# pylint: disable=no-member,not-callable,attribute-defined-outside-init import os from pathlib import Path from textwrap import dedent @@ -20,7 +19,7 @@ def setup_method(self): self.codemod = self.codemod() self.changeset = [] - def run_and_assert( # pylint: disable=too-many-arguments + def run_and_assert( self, tmpdir, input_code, @@ -68,9 +67,7 @@ def run_and_assert( # pylint: disable=too-many-arguments changes[0], ) - def assert_changes( # pylint: disable=too-many-arguments - self, root, file_path, input_code, expected, changes - ): + def assert_changes(self, root, file_path, input_code, expected, changes): expected_diff = create_diff( dedent(input_code).splitlines(keepends=True), dedent(expected).splitlines(keepends=True), @@ -84,7 +81,7 @@ def assert_changes( # pylint: disable=too-many-arguments assert output_code == dedent(expected) - def run_and_assert_filepath( # pylint: disable=too-many-arguments + def run_and_assert_filepath( self, root: Path, file_path: Path, @@ -133,7 +130,7 @@ def create_dir_structure(self, tmpdir): class BaseSASTCodemodTest(BaseCodemodTest): tool: ClassVar = NotImplemented - def run_and_assert( # pylint: disable=too-many-arguments + def run_and_assert( self, tmpdir, input_code, diff --git a/tests/codemods/test_include_exclude.py b/tests/codemods/test_include_exclude.py index 131671f0..b4bf722d 100644 --- a/tests/codemods/test_include_exclude.py +++ b/tests/codemods/test_include_exclude.py @@ -7,9 +7,7 @@ class TestMatchCodemods: @classmethod def setup_class(cls): cls.registry = load_registered_codemods() - cls.codemod_map = ( - cls.registry._codemods_by_name # pylint: disable=protected-access - ) + cls.codemod_map = cls.registry._codemods_by_name cls.default_ids = [ c().id if isinstance(c, type) else c.id for c in registry.codemods ] diff --git a/tests/dependency_management/test_base_dependency_writer.py b/tests/dependency_management/test_base_dependency_writer.py index f2f29086..06f433d1 100644 --- a/tests/dependency_management/test_base_dependency_writer.py +++ b/tests/dependency_management/test_base_dependency_writer.py @@ -5,7 +5,7 @@ class FakeDependencyWriter(DependencyWriter): - def add_to_file( # pylint: disable=useless-return + def add_to_file( self, dependencies: list[Dependency], dry_run: bool = False ) -> ChangeSet | None: del dependencies, dry_run diff --git a/tests/project_analysis/file_parsers/test_pyproject_toml_file_parser.py b/tests/project_analysis/file_parsers/test_pyproject_toml_file_parser.py index 5fd0e423..c5218921 100644 --- a/tests/project_analysis/file_parsers/test_pyproject_toml_file_parser.py +++ b/tests/project_analysis/file_parsers/test_pyproject_toml_file_parser.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name import pytest from codemodder.project_analysis.file_parsers import PyprojectTomlParser diff --git a/tests/project_analysis/file_parsers/test_setup_cfg_file_parser.py b/tests/project_analysis/file_parsers/test_setup_cfg_file_parser.py index 4d273b7f..fd55c9c7 100644 --- a/tests/project_analysis/file_parsers/test_setup_cfg_file_parser.py +++ b/tests/project_analysis/file_parsers/test_setup_cfg_file_parser.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name import pytest from codemodder.project_analysis.file_parsers import SetupCfgParser diff --git a/tests/project_analysis/file_parsers/test_setup_py_file_parser.py b/tests/project_analysis/file_parsers/test_setup_py_file_parser.py index c62b14e4..074eb5d5 100644 --- a/tests/project_analysis/file_parsers/test_setup_py_file_parser.py +++ b/tests/project_analysis/file_parsers/test_setup_py_file_parser.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name import pytest from codemodder.project_analysis.file_parsers import SetupPyParser diff --git a/tests/test_code_directory.py b/tests/test_code_directory.py index 5b7f5f0d..90f8607d 100644 --- a/tests/test_code_directory.py +++ b/tests/test_code_directory.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name from pathlib import Path import pytest