diff --git a/.black.toml b/.black.toml deleted file mode 100644 index 4798838..0000000 --- a/.black.toml +++ /dev/null @@ -1,17 +0,0 @@ -[tool.black] -line-length = 120 -target-version = ['py36', 'py37', 'py38', 'py39'] -exclude = ''' -/( - \.eggs - | \.git - | \.idea - | \.pytest_cache - | \.github - | _build - | build - | dist - | venv - | test/resources -)/ -''' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d595e1..ceddd41 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,18 +30,26 @@ repos: exclude: ^test/resources/.+ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.5 + rev: v0.4.6 hooks: - id: ruff - args: [--extend-ignore, "F401,F403"] - repo: https://github.com/ambv/black rev: 24.4.2 hooks: - id: black - args: [--config=.black.toml] - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v1.10.0' hooks: - id: mypy + +- repo: https://github.com/tox-dev/pyproject-fmt + rev: 2.1.3 + hooks: + - id: pyproject-fmt + +- repo: https://github.com/abravalheri/validate-pyproject + rev: v0.18 + hooks: + - id: validate-pyproject diff --git a/puremagic/__init__.py b/puremagic/__init__.py index f3dfe46..7e53b82 100644 --- a/puremagic/__init__.py +++ b/puremagic/__init__.py @@ -1,3 +1,2 @@ #!/usr/bin/env python -from puremagic.main import __version__, __author__ -from puremagic.main import * +from puremagic.main import __author__, __version__ diff --git a/puremagic/main.py b/puremagic/main.py index 30f4905..b522f90 100644 --- a/puremagic/main.py +++ b/puremagic/main.py @@ -354,8 +354,8 @@ def magic_stream(stream, filename: os.PathLike | str | None = None) -> list[Pure def command_line_entry(*args): - from argparse import ArgumentParser import sys + from argparse import ArgumentParser parser = ArgumentParser( description=( diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..217832c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,66 @@ +[tool.black] +line-length = 120 +target-version = [ + 'py36', + 'py37', + 'py38', + 'py39', +] +exclude = ''' +/( + \.eggs + | \.git + | \.idea + | \.pytest_cache + | \.github + | _build + | build + | dist + | venv + | test/resources +)/ +''' + +[tool.ruff] +line-length = 120 + +lint.select = [ + "ALL", +] +lint.extend-ignore = [ + "ANN", + "B008", + "BLE001", + "C408", + "COM812", + "D", + "EM101", + "EM103", + "EXE001", + "F401", + "F403", + "FBT", + "FIX002", + "N817", + "PERF401", + "PGH003", + "PT", + "PTH", + "PYI024", + "S101", + "S112", + "S314", + "SLF001", + "T201", + "TD002", + "TD003", + "TRY003", + "UP", +] +lint.mccabe.max-complexity = 13 +lint.pylint.allow-magic-value-types = [ + "float", + "int", + "str", +] +lint.pylint.max-branches = 13 diff --git a/scripts/parse_ftk_kessler_sigs.py b/scripts/parse_ftk_kessler_sigs.py index 68eb723..ade7bdc 100644 --- a/scripts/parse_ftk_kessler_sigs.py +++ b/scripts/parse_ftk_kessler_sigs.py @@ -6,10 +6,10 @@ """ -import os -import xml.etree.ElementTree as ET import binascii import json +import os +import xml.etree.ElementTree as ET import puremagic diff --git a/setup.py b/setup.py index 22c581d..38cd0f3 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -from setuptools import setup import os import re +from setuptools import setup root = os.path.abspath(os.path.dirname(__file__)) diff --git a/test/test_common_extensions.py b/test/test_common_extensions.py index 5d102b1..5011025 100644 --- a/test/test_common_extensions.py +++ b/test/test_common_extensions.py @@ -1,9 +1,10 @@ -import unittest -from tempfile import NamedTemporaryFile import os +import unittest from io import BytesIO -import pytest from pathlib import Path +from tempfile import NamedTemporaryFile + +import pytest import puremagic