Skip to content

Commit

Permalink
treewide: remove flake8, add ruff (#353)
Browse files Browse the repository at this point in the history
* treewide: remove flake8, add ruff

ruff is feature-complete (for our purposes) with flake8 and is
an order of magnitude faster.

Signed-off-by: William Woodruff <william@trailofbits.com>

* prproject: configure more `ruff` checks

Signed-off-by: William Woodruff <william@trailofbits.com>

* pyproject: constrain ruff

Ignore a typing problem.

Signed-off-by: William Woodruff <william@trailofbits.com>

* Makefile: `make reformat` runs `ruff --fix`

Signed-off-by: William Woodruff <william@trailofbits.com>

* workflows/ci: constrain lint to our minimum Python version

...since that's our baseline.

Signed-off-by: William Woodruff <william@trailofbits.com>

Signed-off-by: William Woodruff <william@trailofbits.com>
  • Loading branch information
woodruffw authored Dec 22, 2022
1 parent 48d3b08 commit 0647d75
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@d171c3b028d844f2bf14e9fdec0c58114451e4bf
- uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9
with:
python-version: "3.x"
python-version: "3.7"
- name: deps
run: make dev SIGSTORE_EXTRA=lint
- name: lint
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ make lint

* [`black`](https://github.com/psf/black): Code formatting
* [`isort`](https://github.com/PyCQA/isort): Import sorting, ordering
* [`flake8`](https://flake8.pycqa.org/en/latest/): PEP-8 linting, style enforcement
* [`ruff`](https://github.com/charliermarsh/ruff): PEP-8 linting, style enforcement
* [`mypy`](https://mypy.readthedocs.io/en/stable/): Static type checking
* [`bandit`](https://github.com/PyCQA/bandit): Security issue scanning
* [`interrogate`](https://interrogate.readthedocs.io/en/latest/): Documentation coverage
Expand Down Expand Up @@ -142,4 +142,4 @@ with an entry in an appropriate subsection ("Added", "Changed", "Removed", or "F

* Ensure your commits are signed off, as sigstore uses the
[DCO](https://en.wikipedia.org/wiki/Developer_Certificate_of_Origin).
You can do it using `git commit -s`, or `git commit -s --amend` if you want to amend already existing commits.
You can do it using `git commit -s`, or `git commit -s --amend` if you want to amend already existing commits.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ lint: env/pyvenv.cfg
. env/bin/activate && \
black --check $(ALL_PY_SRCS) && \
isort --check $(ALL_PY_SRCS) && \
flake8 $(ALL_PY_SRCS) && \
ruff $(ALL_PY_SRCS) && \
mypy $(PY_MODULE) && \
bandit -c pyproject.toml -r $(PY_MODULE)

.PHONY: reformat
reformat: env/pyvenv.cfg
. env/bin/activate && \
ruff --fix $(ALL_PY_SRCS) && \
black $(ALL_PY_SRCS) && \
isort $(ALL_PY_SRCS)

Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ test = [
]
lint = [
"bandit",
"flake8",
"black",
"isort",
"interrogate",
"mypy",
"ruff",
"types-requests",
# Needed for protocol typing in 3.7; remove when our minimum Python is 3.8.
"typing-extensions; python_version < '3.8'",
Expand Down Expand Up @@ -111,3 +111,10 @@ plugins = ["pydantic.mypy"]

[tool.bandit]
exclude_dirs = ["./test"]

[tool.ruff]
line-length = 100
# TODO: Enable "UP" here once Pydantic allows us to:
# See: https://github.com/pydantic/pydantic/issues/4146
select = ["E", "F", "W"]
target-version = "py37"
2 changes: 1 addition & 1 deletion sigstore/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ def read_embedded(name: str) -> bytes:
Read a resource embedded in this distribution of sigstore-python,
returning its contents as bytes.
"""
return resources.files("sigstore._store").joinpath(name).read_bytes()
return resources.files("sigstore._store").joinpath(name).read_bytes() # type: ignore

0 comments on commit 0647d75

Please sign in to comment.