Skip to content

Commit

Permalink
Enable SLF from ruff (#3228)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Dec 25, 2024
1 parent 070d609 commit ca37ea8
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 403 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Semantic versioning in our case means:
- **Breaking**: Removes `WPS433`, because is covered by `pylint` linter
- **Breaking**: Removes `WPS434`, because is covered by `pylint` linter
- **Breaking**: Removes `WPS436`, because is covered by `pylint` linter
- **Breaking**: Removes `WPS437`, because is covered by `ruff` linter
- **Breaking**: Removes `WPS440`, because
it was buggy and is covered by `mypy`, #3209
- **Breaking**: Removes `WPS442`, because
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ lint.select = [
"RUF", # ruff
"S", # flake8-bandit
"SIM", # flake8-simpify
"SLF", # flake8-self
"SLOT", # flake8-slots
"T100", # flake8-debugger
"TRY", # tryceratops
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def options():
"""Returns the options builder."""
default_values = {
option.long_option_name[2:].replace('-', '_'): option.default
for option in Configuration._options # noqa: WPS437
for option in Configuration._options # noqa: SLF001
}

Options = namedtuple('options', default_values.keys())
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/formatter/formatter2.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def data(param) -> int:
return param._protected + 10_00
return s + 10_00
2 changes: 0 additions & 2 deletions tests/fixtures/noqa/noqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ class Mem0Output: # noqa: WPS124
# https://github.com/wemake-services/wemake-python-styleguide/issues/1191
anti_wps124 = 'unreadable class'

some._execute() # noqa: WPS437


def many_locals(): # noqa: WPS210
arg1, arg2, arg3, arg4, arg5, arg6 = range(6) # noqa: WPS236
Expand Down
16 changes: 8 additions & 8 deletions tests/fixtures/notebook.ipynb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Correct cell"
],
"cell_type": "markdown",
"metadata": {}
]
},
{
"cell_type": "code",
Expand All @@ -19,11 +19,11 @@
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Incorrect cells"
],
"cell_type": "markdown",
"metadata": {}
]
},
{
"cell_type": "code",
Expand All @@ -42,7 +42,7 @@
"outputs": [],
"source": [
"def data(param) -> int:\n",
" return param._protected + 10_00"
" return s + 10_00"
]
},
{
Expand Down Expand Up @@ -75,4 +75,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
2 changes: 1 addition & 1 deletion tests/test_checker/test_exception_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_exception_handling(
"""Ensures that checker works with module names."""
Checker.parse_options(default_options)
checker = Checker(tree=ast.parse(''), file_tokens=[], filename='test.py')
checker._visitors = [_BrokenVisitor] # noqa: WPS437
checker._visitors = [_BrokenVisitor] # noqa: SLF001

with suppress(StopIteration):
violation = next(checker.run())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_checker/test_noqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
'WPS434': 0, # disabled since 1.0.0
'WPS435': 1,
'WPS436': 0, # disabled since 1.0.0
'WPS437': 1,
'WPS437': 0, # disabled since 1.0.0
'WPS438': 4,
'WPS439': 1,
'WPS440': 0, # disabled since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion tests/test_checker/test_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_all_visitors_contained_in_checker(all_visitors): # noqa: WPS442
"""Ensures that all visitors are contained in a checker."""
checker_visitors = {
klass.__qualname__
for klass in Checker._visitors # noqa: WPS437
for klass in Checker._visitors # noqa: SLF001
if not klass.__qualname__.startswith('_')
}

Expand Down
Loading

0 comments on commit ca37ea8

Please sign in to comment.