Skip to content

Commit

Permalink
internal: switch to ruff for formatting/linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mik3y committed Aug 10, 2024
1 parent 44bcf9a commit 6a0432f
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 518 deletions.
14 changes: 5 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ repos:
args: []
additional_dependencies: ['poetry']

- repo: https://github.com/pycqa/isort
rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- id: ruff
args: [--fix]
- id: ruff-format
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Current version (in development)

* Internal: Switch Python code formatter/linter to [ruff](https://docs.astral.sh/ruff/).

## v1.0.0 (2023-12-25)

* Feature: Added `monkey_patch_drf()` utility.
Expand Down
8 changes: 4 additions & 4 deletions django_spicy_id/baseconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
Copyright (c) 2010 Guilherme Gondim. All rights reserved.
Copyright (c) 2009 Simon Willison. All rights reserved.
Copyright (c) 2002 Drew Perttula. All rights reserved.
License:
Python Software Foundation License version 2
See the file "LICENSE" for terms & conditions for usage, and a DISCLAIMER OF
ALL WARRANTIES.
This Baseconv distribution contains no GNU General Public Licensed (GPLed)
code so it may be used in proprietary projects just like prior ``baseconv``
distributions.
All trademarks referenced herein are property of their respective holders.
"""

Expand Down
2 changes: 1 addition & 1 deletion django_spicy_id/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
**kwargs,
):
if not self.NUM_BITS:
raise NotImplemented(
raise NotImplementedError(
"attempt to init abstract base class, or subclass has failed to set NUM_BITS"
)
if encoding not in CODECS_BY_ENCODING:
Expand Down
8 changes: 4 additions & 4 deletions django_spicy_id/tests/baseconv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
Copyright (c) 2010 Guilherme Gondim. All rights reserved.
Copyright (c) 2009 Simon Willison. All rights reserved.
Copyright (c) 2002 Drew Perttula. All rights reserved.
License:
Python Software Foundation License version 2
See the file "LICENSE" for terms & conditions for usage, and a DISCLAIMER OF
ALL WARRANTIES.
This Baseconv distribution contains no GNU General Public Licensed (GPLed)
code so it may be used in proprietary projects just like prior ``baseconv``
distributions.
All trademarks referenced herein are property of their respective holders.
"""

Expand Down
2 changes: 1 addition & 1 deletion django_spicy_id/tests/fields_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db.utils import ProgrammingError
from django.test import TestCase

from django_spicy_id import MalformedSpicyIdError, SpicyAutoField
from django_spicy_id import SpicyAutoField
from django_spicy_id.fields import LEGAL_PREFIX_RE
from django_spicy_id.tests import models

Expand Down
2 changes: 1 addition & 1 deletion django_spicy_id/tests/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_valid_spicy_urls_hex(self):
response = c.get(f"/example/hex-nopad/{bad_id}")
self.assertEqual(404, response.status_code, f"expected 404 for {bad_id}")

def test_valid_spicy_urls_hex(self):
def test_valid_spicy_urls_b58(self):
c = Client()

# Valid IDs.
Expand Down
831 changes: 393 additions & 438 deletions poetry.lock

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,26 @@ license = "MIT"
[tool.poetry.dependencies]
python = "^3.9.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
flake8 = "^6.0.0"
black = "^22.12.0"
isort = "^5.12.0"
tox = "^4.6.3"
setuptools = "^65.7.0"
pytest-django = "^4.5.2"

[tool.poetry.group.dev.dependencies]
sphinx = "^6.1.3"
twine = "^4.0.2"
ruff = "^0.5.7"

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

[tool.isort]
profile = "black"
skip_gitignore = true

[tool.black]
[tool.ruff]
line-length = 100
target_version = ['py311']
include = 'django_spicy_id/.*\.pyi?$'
target-version = 'py312'
exclude = [
".git",
"node_modules",
".pyenv",
".vscode",
".tox"
]
22 changes: 0 additions & 22 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,3 @@ parallel = True

[coverage:report]
show_missing = True

[flake8]
exclude =
.tox,
.git,
__pycache__,
build,
dist
ignore = W503,W504
max_line_length = 99

[isort]
combine_as_imports = True
default_section = THIRDPARTY
force_grid_wrap = 0
include_trailing_comma = True
known_third_party = Django
known_first_party = django_spicy_id
line_length = 99
multi_line_output = 3
skip = .tox,venv
use_parentheses = True
26 changes: 1 addition & 25 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
isolated_build = true
envlist =
py{39,310,311,312}-django{22,31,41}-{mysql,postgres,sqlite}, flake8, isort, dist
py{39,310,311,312}-django{22,31,41}-{mysql,postgres,sqlite}, dist

[gh-actions]
python =
Expand Down Expand Up @@ -55,30 +55,6 @@ passenv =

usedevelop = True

[testenv:black]
commands =
black -l 99 -t py311 --check --diff {posargs}
deps =
black

[testenv:black-fix]
commands =
black -l 99 -t py311 .
deps =
black

[testenv:flake8]
commands =
flake8 {posargs}
deps =
flake8

[testenv:isort]
commands =
isort --check-only --diff src tests
deps =
isort

[testenv:dist]
commands =
twine check .tox/dist/*
Expand Down

0 comments on commit 6a0432f

Please sign in to comment.