Skip to content

Commit

Permalink
Replace Flake8 with Ruff (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Feb 8, 2024
2 parents fdfa052 + ff6802e commit d5a3786
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 40 deletions.
5 changes: 1 addition & 4 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma:
pragma: no cover

exclude_also =
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
def main
Expand Down
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

11 changes: 7 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ jobs:
# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: |
github.repository_owner == 'hugovk'
&& github.event_name == 'push'
&& github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-package

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
Expand All @@ -53,12 +55,13 @@ jobs:
# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
if: github.event.action == 'published'
if: |
github.repository_owner == 'hugovk'
&& github.event.action == 'published'
runs-on: ubuntu-latest
needs: build-package

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Lint

on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

permissions:
contents: read

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/require-pr-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:

permissions:
issues: write
pull-requests: write

steps:
- uses: mheap/github-action-required-labels@v5
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
Expand Down
41 changes: 14 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: pyupgrade
args: [--py310-plus]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: [--add-import=from __future__ import annotations]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
[flake8-2020, flake8-errmsg, flake8-implicit-str-concat]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-no-log-warn

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand All @@ -37,6 +18,7 @@ repos:
- id: check-json
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace

Expand All @@ -46,17 +28,17 @@ repos:
- id: mypy
args: [--strict, --pretty, --show-error-codes, .]
additional_dependencies:
[httpx, platformdirs, pytest, types-freezegun, types-python-slugify]
[httpx, platformdirs, pytest, python-slugify, types-freezegun]
pass_filenames: false

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.5.3
rev: 1.7.0
hooks:
- id: pyproject-fmt
additional_dependencies: [tox]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: v0.16
hooks:
- id: validate-pyproject

Expand All @@ -71,5 +53,10 @@ repos:
- id: prettier
args: [--prose-wrap=always, --print-width=88]

- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes

ci:
autoupdate_schedule: quarterly
27 changes: 25 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,31 @@ version.source = "vcs"
[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

[tool.isort]
profile = "black"
[tool.ruff.lint]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle errors
"EM", # flake8-errmsg
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
]
extend-ignore = [
"E203", # Whitespace before ':'
"E221", # Multiple spaces before operator
"E226", # Missing whitespace around arithmetic operator
"E241", # Multiple spaces after ','
]

[tool.ruff.lint.isort]
known-first-party = ["linkotron"]
required-imports = ["from __future__ import annotations"]

[tool.pytest.ini_options]
addopts = "--color=yes"
1 change: 1 addition & 0 deletions src/linkotron/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
CLI to format links
"""

from __future__ import annotations

import importlib.metadata
Expand Down
1 change: 1 addition & 0 deletions src/linkotron/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
linkotron: CLI to format GitHub links in a shorter format.
"""

from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions tests/test_linkotron.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Unit tests
"""

from __future__ import annotations

import pytest
Expand Down

0 comments on commit d5a3786

Please sign in to comment.