diff options
author | Hugo Osvaldo Barrera <hugo@whynothugo.nl> | 2023-02-10 17:04:30 +0100 |
---|---|---|
committer | Hugo <hugo@whynothugo.nl> | 2023-05-24 14:20:00 +0200 |
commit | f37b28a607c913a906c371366fac75ab242edec6 (patch) | |
tree | 26782f37a33184b6640a3aba737fce3bccec5486 | |
parent | e888014e0b2bfb2e6d22d1857d8b24a7823fa2fa (diff) |
Use Ruff for code linting and checking
Ruff does the same as flake8(+plugins)+pyupgrade+isort, but much faster
and can also automatically fix many of these quirks too.
It ignores all files that are ignored by git, so all the exclude rules
are not necessary.
I have left isort-related rules out for now since they results in some
changes which might add noise at this point.
-rw-r--r-- | .pre-commit-config.yaml | 18 | ||||
-rw-r--r-- | doc/source/hacking.rst | 4 | ||||
-rw-r--r-- | khal/khalendar/event.py | 2 | ||||
-rw-r--r-- | pyproject.toml | 5 | ||||
-rw-r--r-- | tox.ini | 8 |
5 files changed, 13 insertions, 24 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7cdee0b2..84dae0b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,19 +13,6 @@ repos: hooks: - id: isort name: isort (python) - - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - additional_dependencies: - - flake8-comprehensions - - flake8-bugbear - exclude: doc/source/conf.py - - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 - hooks: - - id: pyupgrade - args: [--py36-plus] - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.0.0 hooks: @@ -37,3 +24,8 @@ repos: - types-pytz - types-setuptools - types-python-dateutil + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.244' + hooks: + - id: ruff + args: ["--fix"] diff --git a/doc/source/hacking.rst b/doc/source/hacking.rst index 9df986aa..33bf0df5 100644 --- a/doc/source/hacking.rst +++ b/doc/source/hacking.rst @@ -127,7 +127,7 @@ Code Style khal's source code should adhere to the rules laid out in :pep:`008`, except for allowing line lengths of up to 100 characters if it improves overall legibility (use your judgement). This can be checked by installing and -running flake8_ (run with :command:`flake8` from khal's source directory), which +running ruff_ (run with :command:`ruff` from khal's source directory), which will also be run with tox and GitHub Actions, see section above. We try to document the parameters functions and methods accept, including their @@ -148,7 +148,7 @@ identifiers, e.g., in dictionary keys:: .. _tox: https://tox.readthedocs.org/ .. _pytest: http://pytest.org/ .. _pytest-cov: https://pypi.python.org/pypi/pytest-cov -.. _flake8: http://flake8.pycqa.org/ +.. _ruff: https://github.com/charliermarsh/ruff .. _sphinx: http://www.sphinx-doc.org .. _restructuredtext: http://www.sphinx-doc.org/en/1.5.1/rest.html .. _ipdb: https://pypi.python.org/pypi/ipdb diff --git a/khal/khalendar/event.py b/khal/khalendar/event.py index 8f3a88fc..a653f94f 100644 --- a/khal/khalendar/event.py +++ b/khal/khalendar/event.py @@ -209,7 +209,7 @@ class Event: beware, this methods performs some open heart surgery """ - if type(start) != type(end): # flake8: noqa + if type(start) != type(end): raise ValueError('DTSTART and DTEND should be of the same type (datetime or date)') self.__class__ = self._get_type_from_date(start) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..537cc6ed --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.ruff] +select = ["E", "F", "W", "B0", "UP", "C4"] +ignore = ["B008"] +line-length = 100 +target-version = "py38" @@ -42,14 +42,6 @@ commands = make -C doc html make -C doc man -[flake8] -max-line-length = 100 -ignore = E252,W504,E121,B008 -exclude = .tox,examples,doc -extend-ignore = - # Line jump before binary operator. - W503, - [mypy] # Silence warnings given by using untyped libraries: ignore_missing_imports = True |