Skip to content

Commit

Permalink
Must not use explicit object base-class (#2888)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Mar 25, 2024
1 parent 47d71a3 commit 43a966f
Show file tree
Hide file tree
Showing 101 changed files with 2,015 additions and 2,048 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Install remark presets
run: |
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ Semantic versioning in our case means:

### Features

- Adds official `python3.12` support
- **Breaking**: drops `python3.8` support
- **Breaking**: Reconsider `object` required base class exception:
since `class Klass[_Type]` must not contain `object`,
this rule is change to be the opposite:
`object` explicit base class must not be used.
You can use `ruff` to change all `object`-based types to the new style:
`ruff check --select=UP004 --fix .`
https://docs.astral.sh/ruff/rules/useless-object-inheritance/
- `wemake` output formatter now respects `NO_COLOR=1` option
to disable text highlighting. See https://no-color.org
- Add `ImportObjectCollisionViolation` to detect
Expand All @@ -31,10 +40,12 @@ Semantic versioning in our case means:
- Fix `ForbiddenInlineIgnoreViolation` config parsing. #2590
- Fix `WrongEmptyLinesCountViolation` for func definitions with ellipsis. #2847
- Fix `WrongEmptyLinesCountViolation` for multiline implicit string concatination. #2787
- Fix `ObjectInBaseClassesListViolation` to include type name

### Misc

- Replaced `you` with `your`
- Fixed multiple typos in docs


## 0.18.0

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/usage/integrations/pylint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ that ``pylint`` is less radical and more classic in its rules.
They are almost compatible with each other.
The difference is in:

- Several minor rules like `class Some(object):` vs `class Some:`
- Several minor rules like `class Some:` vs `class Some:`
- Error codes
- Python versions, because ``pylint`` covers more versions
- ``wemake-python-styleguide`` is stricter and finds more
Expand Down
1,163 changes: 487 additions & 676 deletions poetry.lock

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ WPS = "wemake_python_styleguide.checker:Checker"
wemake = "wemake_python_styleguide.formatter:WemakeFormatter"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
python = "^3.9"

flake8 = ">5"
attrs = "*"
Expand All @@ -60,7 +60,7 @@ flake8-quotes = "^3.0"
flake8-comprehensions = "^3.1"
flake8-docstrings = "^1.3"
flake8-string-format = "^0.3"
flake8-bugbear = ">=23.5,<25.0"
flake8-bugbear = "^24.2"
flake8-debugger = "^4.0"
flake8-isort = "^6.0"
flake8-eradicate = "^1.5"
Expand All @@ -71,41 +71,41 @@ pep8-naming = "^0.13"
darglint = "^1.2"

[tool.poetry.group.dev.dependencies]
nitpick = ">=0.33,<0.36"
nitpick = "^0.35"
flake8-pytest-style = "^1.5"

pytest = ">=7.3,<9.0"
pytest-cov = ">=4,<6"
pytest = "^8.1"
pytest-cov = "^5.0"
pytest-randomly = "^3.12"
coverage-conditional-plugin = ">=0.8,<0.10"
snapshottest = "^0.6"
coverage-conditional-plugin = "^0.9"
syrupy = "^4.6"
hypothesis = "^6.35"
hypothesmith = ">=0.2,<0.4"
hypothesmith = "^0.3"

mypy = "^1.3"
mypy = "^1.9"

autopep8 = "^2.0"
import-linter = ">=1.2,<3.0"
import-linter = "^2.0"

astpath = "^0.9"
lxml = ">=4.9,<6.0"
lxml = "^5.1"
nbqa = "^1.2"
doc8 = ">=0.11,<1.2"
doc8 = "^1.1"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = ">=6.2,<8.0"
sphinx-autodoc-typehints = ">=1.12,<3.0"
sphinx = "^7.1"
sphinx-autodoc-typehints = "^2.0"
sphinxcontrib-mermaid = "^0.9"
added-value = "^0.24"
m2r2 = "^0.3"
tomli = "^2.0"


[build-system]
requires = ["poetry-core>=1.6.0"]
requires = ["poetry-core>=1.9.0"]
build-backend = "poetry.core.masonry.api"


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exclude =
# These folders contain code badly written for reasons:
# Project spefic, do not copy.
tests/fixtures/**
tests/**/snapshots/**
tests/**/__snapshots__/**

# Exclude some pydoctest checks globally:
ignore = D100, D104, D401, W504, RST303, RST304, DAR103, DAR203
Expand Down
26 changes: 13 additions & 13 deletions tests/fixtures/noqa/noqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def foo_func():
my_print('nope')


class TooManyPublicAtts(object): # noqa: WPS230
class TooManyPublicAtts: # noqa: WPS230
def __init__(self):
self.first = 1
self.second = 2
Expand All @@ -126,7 +126,7 @@ def function_name( # noqa: WPS614
def some(): # noqa: WPS110
from my_module import some_import # noqa: WPS433

class Nested(object): # noqa: WPS431
class Nested: # noqa: WPS431
... # noqa: WPS428, WPS604

def nested(): # noqa: WPS430
Expand Down Expand Up @@ -155,7 +155,7 @@ def some_function():

used, __ = 1, 2 # noqa: WPS123

class Mem0Output(object): # noqa: WPS124
class Mem0Output: # noqa: WPS124
# See:
# https://github.com/wemake-services/wemake-python-styleguide/issues/1191
anti_wps124 = 'unreadable class'
Expand Down Expand Up @@ -203,7 +203,7 @@ def many_expressions(xy): # noqa: WPS213
my_print(xy)


class TooManyMethods(object): # noqa: WPS214
class TooManyMethods: # noqa: WPS214
def method1(self):
anti_wps428 = 1

Expand Down Expand Up @@ -290,13 +290,13 @@ def test_function(): # noqa: WPS231
my_print('type')


class BadClass: # noqa: WPS306
class BadClass(object): # noqa: WPS306
UPPER_CASE_ATTRIBUTE = 12 # noqa: WPS115

def __del__(self, *_args, **_kwargs): # noqa: WPS603
anti_wps428 = 1 # noqa: WPS442

class Nested: # noqa: WPS306,WPS431
class Nested(object): # noqa: WPS306,WPS431
anti_wps428 = 1

async def __eq__(self, other): # noqa: WPS610
Expand Down Expand Up @@ -435,7 +435,7 @@ class MyInt(int): # noqa: WPS600
"""My custom int subclass."""


class ShadowsAttribute(object):
class ShadowsAttribute:
"""Redefines attr from class."""

first: int
Expand All @@ -459,7 +459,7 @@ def __init__(self) -> None:
nodes = nodes # noqa: WPS434


class Example(object):
class Example:
"""Correct class docstring."""

def __init__(self): # noqa: WPS611
Expand Down Expand Up @@ -575,7 +575,7 @@ def bad_default_values(
anti_wps428 = 'some text'


class WrongMethodOrder(object): # noqa: WPS338
class WrongMethodOrder: # noqa: WPS338
def _protected(self):
return self

Expand Down Expand Up @@ -627,7 +627,7 @@ async def async_gen():
raise StopIteration # noqa: WPS438


class CheckStopIteration(object):
class CheckStopIteration:
def sync_gen(self):
yield
raise StopIteration() # noqa: WPS438
Expand Down Expand Up @@ -717,7 +717,7 @@ def consecutive_yields():
[first_number, second_number] = [4, 7] # noqa: WPS359


class AttributeGetter(object):
class AttributeGetter:
def __init__(self):
self.attribute = 1

Expand Down Expand Up @@ -808,7 +808,7 @@ def bare_raise_function():
raise raise_from_itself from raise_from_itself # noqa: WPS469


class TestClass(object, **{}): # noqa: WPS470
class TestClass(**{}): # noqa: WPS470
"""Docs."""


Expand All @@ -820,7 +820,7 @@ def foo2_func():

noqa_wps532 = variable is some_thing is other_thing # noqa: WPS532

class Baseline(object):
class Baseline:
def method(self, number):
return number + 1

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/noqa/noqa38.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""


class WithStatic(object):
class WithStatic:
@staticmethod
def some_static(arg1): # noqa: WPS602
anti_wps428 = 1
Expand Down

0 comments on commit 43a966f

Please sign in to comment.