Skip to content

Commit

Permalink
Replace flake8, flake8-naming, and pep8 with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed May 21, 2023
1 parent 3e768a8 commit 462338c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-alpha - 3.11"]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mock pep8 flake8 pep8-naming
pip install mock ruff
- name: Test
run: python setup.py test
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,5 @@ ln -s ../../pre-commit.sh .git/hooks/pre-commit
Then install dev requirements:

```bash
pip install pep8
pip install flake8
pip install pep8-naming
pip install ruff
```
2 changes: 1 addition & 1 deletion code-check.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
flake8 cron_descriptor tests examples --max-line-length=120 --builtins=_
ruff .
74 changes: 74 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[tool.ruff]
select = [
"A", # flake8-builtins
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
"DTZ", # flake8-datetimez
"E", # pycodestyle
"EXE", # flake8-executable
"F", # Pyflakes
"FA", # flake8-future-annotations
"FBT", # flake8-boolean-trap
"FLY", # flynt
"ICN", # flake8-import-conventions
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # flake8-self
"T10", # flake8-debugger
"TCH", # flake8-type-checking
"TD", # flake8-todos
"TID", # flake8-tidy-imports
"W", # pycodestyle
"YTT", # flake8-2020
# "ANN", # flake8-annotations
# "ARG", # flake8-unused-arguments
# "COM", # flake8-commas
# "D", # pydocstyle
# "DJ", # flake8-django
# "EM", # flake8-errmsg
# "ERA", # eradicate
# "G", # flake8-logging-format
# "I", # isort
# "INP", # flake8-no-pep420
# "NPY", # NumPy-specific rules
# "PD", # pandas-vet
# "PTH", # flake8-use-pathlib
# "Q", # flake8-quotes
# "T20", # flake8-print
# "TRY", # tryceratops
# "UP", # pyupgrade
]
ignore = ["N999", "PT009"]
line-length = 159
target-version = "py37"

[tool.ruff.mccabe]
max-complexity = 20

[tool.ruff.pylint]
allow-magic-value-types = ["int", "str"]
max-args = 8
max-branches = 16

[tool.ruff.per-file-ignores]
"cron_descriptor/Exception.py" = ["N818", "PIE790"]
"cron_descriptor/ExpressionDescriptor.py" = ["B904", "BLE001", "DTZ011", "PLC1901", "RET505"]
"cron_descriptor/ExpressionParser.py" = ["RET506"]
"setup.py" = ["SIM115"]
"tests/*" = ["PLR0402", "S101"]
"tests/TestLocale.py" = ["PIE804"]
"tools/resx2po.py" = ["N817", "S314"]
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
long_description = open('README.md', encoding='utf-8').read()
else:
long_description = open('README.md').read()

setuptools.setup(
name="cron_descriptor",
version="1.4.0",
Expand Down Expand Up @@ -72,9 +72,7 @@
]
},
tests_require=[
'pep8',
'flake8',
'pep8-naming'
'ruff',
],
test_suite="tests"
)
8 changes: 5 additions & 3 deletions tests/TestLocale.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import tests.TestCase as TestCase
from cron_descriptor import Options, ExpressionDescriptor
from unittest.mock import patch
import tempfile, shutil, os
import tempfile
import shutil
import os
import logging


Expand All @@ -49,6 +51,6 @@ def test_locale_de_custom_location(self):
options.locale_location = temp_dir
options.locale_code = 'de_DE'
options.use_24hour_time_format = True

self.assertEqual("Jede Minute", ExpressionDescriptor("* * * * *", options).get_description())
mock_logger.assert_called_once_with("{temp_path} Loaded".format(**{"temp_path":temp_path}))
mock_logger.assert_called_once_with("{temp_path} Loaded".format(**{"temp_path":temp_path}))
2 changes: 1 addition & 1 deletion tools/resx2po.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ def generate(self):
Path('Resources.{}.resx'.format(from_code)),
to_code,
output_file
)
)

0 comments on commit 462338c

Please sign in to comment.