Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace flake8, flake8-naming, and pep8 with ruff #72

Merged
merged 1 commit into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-alpha - 3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-alpha - 3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -20,6 +20,6 @@ jobs:
- 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"]
21 changes: 5 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@
# SOFTWARE.

import setuptools
import sys


if __name__ == "__main__":
if sys.version_info >= (3, 0):
long_description = open('README.md', encoding='utf-8').read()
else:
long_description = open('README.md').read()

with open('README.md', encoding='utf-8') as in_file:
long_description = in_file.read()

setuptools.setup(
name="cron_descriptor",
version="1.4.0",
Expand All @@ -53,17 +50,11 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development",
],
extras_require={
Expand All @@ -72,9 +63,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
)
)