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

treewide: replace flake8 with ruff #35

Merged
merged 3 commits into from
Feb 1, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ lint: $(VENV_EXISTS)
. $(VENV_BIN)/activate && \
black --check $(ALL_PY_SRCS) && \
isort --check $(ALL_PY_SRCS) && \
flake8 $(ALL_PY_SRCS) && \
ruff $(ALL_PY_SRCS) && \
mypy $(PY_MODULE)
# TODO: Enable.
# interrogate -c pyproject.toml .

.PHONY: format
format:
format: $(VENV_EXISTS)
. $(VENV_BIN)/activate && \
ruff --fix $(ALL_PY_SRCS) && \
black $(ALL_PY_SRCS) && \
isort $(ALL_PY_SRCS)

Expand Down
7 changes: 4 additions & 3 deletions abi3audit/_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

import logging
import re
from collections.abc import Iterator
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Iterator, Optional, Union
from typing import Union
from zipfile import ZipFile

from packaging import utils
Expand Down Expand Up @@ -122,7 +123,7 @@ class WheelExtractor:
This extractor collects and yields each shared object in the specified wheel.
"""

def __init__(self, spec: WheelSpec, parent: Optional[PyPIExtractor] = None) -> None:
def __init__(self, spec: WheelSpec, parent: PyPIExtractor | None = None) -> None:
self.spec = spec
self.path = Path(self.spec)
self.parent = parent
Expand Down Expand Up @@ -158,7 +159,7 @@ class SharedObjectExtractor:
the spec it created with.
"""

def __init__(self, spec: SharedObjectSpec, parent: Optional[WheelExtractor] = None) -> None:
def __init__(self, spec: SharedObjectSpec, parent: WheelExtractor | None = None) -> None:
self.spec = spec
self.path = Path(self.spec)
self.parent = parent
Expand Down
5 changes: 3 additions & 2 deletions abi3audit/_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import logging
import struct
from typing import Iterator, Optional, Union
from collections.abc import Iterator
from typing import Union

import pefile
from abi3info.models import PyVersion, Symbol
Expand All @@ -31,7 +32,7 @@ def __init__(self, extractor: extract.SharedObjectExtractor):
self._extractor = extractor
self.path = self._extractor.path

def abi3_version(self, assume_lowest: PyVersion = PyVersion(3, 2)) -> Optional[PyVersion]:
def abi3_version(self, assume_lowest: PyVersion = PyVersion(3, 2)) -> PyVersion | None:
# If we're dealing with a shared object that was extracted from a wheel,
# we try and suss out the abi3 version from the wheel's own tags.
if self._extractor.parent is not None:
Expand Down
6 changes: 4 additions & 2 deletions abi3audit/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
`abi3audit` CLI state, broken out to avoid circular imports.
"""

from __future__ import annotations

import os
import sys
from typing import Literal, Optional
from typing import Literal

from rich.console import Console

# TODO: Remove this once rich's NO_COLOR handling is fixed.
# See: https://github.com/Textualize/rich/issues/2549
_color_system: Optional[Literal["auto"]]
_color_system: Literal["auto"] | None
if os.getenv("NO_COLOR", None) is not None:
_color_system = None
else:
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ test = [
]
lint = [
"bandit",
"flake8",
"black",
"isort",
"interrogate",
"mypy",
"ruff",
"types-requests",
]
dev = [
Expand Down Expand Up @@ -98,3 +98,8 @@ line-length = 100

[tool.coverage.run]
omit = ["abi3audit/_vendor/*"]

[tool.ruff]
line-length = 100
select = ["E", "F", "W", "UP"]
target-version = "py38"