diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b56f486..bf86c1f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,66 +1,47 @@ repos: - - repo: local + # Modifiers + - repo: https://github.com/psf/black + rev: 24.10.0 hooks: - - id: bandit - name: bandit - entry: bandit - language: system - types: [python] - require_serial: true - args: ["-c", "bandit.yml"] - id: black - name: black - entry: black - language: system - types: [python] - require_serial: true + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + + - repo: https://github.com/asottile/pyupgrade + rev: v3.19.0 + hooks: + - id: pyupgrade + args: [--py38-plus] + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--filter-files"] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + # Modifiers + - id: trailing-whitespace + # Static Checkers - id: check-added-large-files - name: Check for added large files - entry: check-added-large-files - language: system - id: check-toml - name: Check Toml - entry: check-toml - language: system - types: [toml] - id: check-yaml - name: Check Yaml - entry: check-yaml - language: system - types: [yaml] - id: end-of-file-fixer - name: Fix End of Files - entry: end-of-file-fixer - language: system - types: [text] - stages: [commit, push, manual] + + - repo: https://github.com/pycqa/flake8 + rev: 7.1.1 + hooks: - id: flake8 - name: flake8 - entry: flake8 - language: system - types: [python] - require_serial: true - - id: isort - name: isort - entry: isort - require_serial: true - language: system - types_or: [cython, pyi, python] - args: ["--filter-files"] - - id: pyupgrade - name: pyupgrade - description: Automatically upgrade syntax for newer versions. - entry: pyupgrade - language: system - types: [python] - args: [--py38-plus] - - id: trailing-whitespace - name: Trim Trailing Whitespace - entry: trailing-whitespace-fixer - language: system - types: [text] - stages: [commit, push, manual] - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.1.2 + + # Static Checkers + - repo: https://github.com/PyCQA/bandit + rev: 1.7.10 hooks: - - id: prettier + - id: bandit + additional_dependencies: [".[toml]"] + args: ["-c", "bandit.yml"] diff --git a/docs/conf.py b/docs/conf.py index a3c094c..3dcbdb3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,5 @@ """Sphinx configuration.""" + from datetime import datetime diff --git a/src/human_readable/__init__.py b/src/human_readable/__init__.py index 7e0095c..f6eedd3 100644 --- a/src/human_readable/__init__.py +++ b/src/human_readable/__init__.py @@ -1,4 +1,5 @@ """Human Readable.""" + from human_readable.files import file_size from human_readable.i18n import activate from human_readable.i18n import deactivate diff --git a/src/human_readable/i18n.py b/src/human_readable/i18n.py index dd17029..ec2eddf 100644 --- a/src/human_readable/i18n.py +++ b/src/human_readable/i18n.py @@ -1,4 +1,5 @@ """Activate, get and deactivate translations.""" + from __future__ import annotations import gettext as gettext_module diff --git a/src/human_readable/lists.py b/src/human_readable/lists.py index 0757019..3edb198 100644 --- a/src/human_readable/lists.py +++ b/src/human_readable/lists.py @@ -1,4 +1,5 @@ """Tests for lists humanization.""" + from __future__ import annotations diff --git a/src/human_readable/numbers.py b/src/human_readable/numbers.py index eeb8fde..b7c61ed 100644 --- a/src/human_readable/numbers.py +++ b/src/human_readable/numbers.py @@ -1,4 +1,5 @@ """Humanizing functions for numbers.""" + from __future__ import annotations import fractions diff --git a/src/human_readable/times.py b/src/human_readable/times.py index a4a2be9..c0edfbe 100644 --- a/src/human_readable/times.py +++ b/src/human_readable/times.py @@ -1,4 +1,5 @@ """Time humanizing functions.""" + from __future__ import annotations import datetime as dt diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 2136b55..f724986 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -1,4 +1,5 @@ """Fixtures for functional tests.""" + import pytest from pytest_mock import MockerFixture diff --git a/tests/functional/en_ABBR/test_numbers.py b/tests/functional/en_ABBR/test_numbers.py index d63938f..a286531 100644 --- a/tests/functional/en_ABBR/test_numbers.py +++ b/tests/functional/en_ABBR/test_numbers.py @@ -1,4 +1,5 @@ """Tests for ru_RU numbers humanizing.""" + from pytest_mock import MockerFixture import human_readable diff --git a/tests/functional/en_ABBR/test_times.py b/tests/functional/en_ABBR/test_times.py index 34bc433..baee85e 100644 --- a/tests/functional/en_ABBR/test_times.py +++ b/tests/functional/en_ABBR/test_times.py @@ -1,4 +1,5 @@ """Tests for time humanizing.""" + import datetime as dt import pytest diff --git a/tests/functional/fr_FR/test_numbers.py b/tests/functional/fr_FR/test_numbers.py index 8549f19..f823819 100644 --- a/tests/functional/fr_FR/test_numbers.py +++ b/tests/functional/fr_FR/test_numbers.py @@ -1,4 +1,5 @@ """Tests for fr_FR numbers humanizing.""" + from pytest_mock import MockerFixture import human_readable.numbers as numbers diff --git a/tests/functional/pt_BR/test_numbers.py b/tests/functional/pt_BR/test_numbers.py index 2a7aa05..34bb882 100644 --- a/tests/functional/pt_BR/test_numbers.py +++ b/tests/functional/pt_BR/test_numbers.py @@ -1,4 +1,5 @@ """Tests for pt_BR numbers humanizing.""" + import pytest from pytest_mock import MockerFixture diff --git a/tests/functional/pt_BR/test_times.py b/tests/functional/pt_BR/test_times.py index 303bfd2..21256c9 100644 --- a/tests/functional/pt_BR/test_times.py +++ b/tests/functional/pt_BR/test_times.py @@ -1,4 +1,5 @@ """Tests for pt_BR time humanizing.""" + from __future__ import annotations import datetime as dt diff --git a/tests/functional/ru_RU/test_numbers.py b/tests/functional/ru_RU/test_numbers.py index c244a34..5fce1a0 100644 --- a/tests/functional/ru_RU/test_numbers.py +++ b/tests/functional/ru_RU/test_numbers.py @@ -1,4 +1,5 @@ """Tests for ru_RU numbers humanizing.""" + from pytest_mock import MockerFixture import human_readable.numbers as numbers diff --git a/tests/functional/ru_RU/test_times.py b/tests/functional/ru_RU/test_times.py index 30dbb61..fc48ea3 100644 --- a/tests/functional/ru_RU/test_times.py +++ b/tests/functional/ru_RU/test_times.py @@ -1,4 +1,5 @@ """Tests for time humanizing.""" + import datetime as dt from pytest_mock import MockerFixture diff --git a/tests/unit/test_files.py b/tests/unit/test_files.py index d8887df..bcc7b1a 100644 --- a/tests/unit/test_files.py +++ b/tests/unit/test_files.py @@ -1,4 +1,5 @@ """Tests for file size humanization.""" + from __future__ import annotations import pytest @@ -55,12 +56,30 @@ def test_file_size_gnu(params: tuple[int, bool, bool], expected: str) -> None: "params, expected", [ ((1, False, True, ".3f", ".1f"), "1.0B"), # unit number (small formatting) - ((999, False, False, ".3f", ".1f"), "999.0 Bytes"), # hundreds number (small formatting) - ((1000, False, False, ".3f", ".1f"), "1.000 KB"), # hundreds number (small formatting boundary) - ((1023, False, True, ".3f", ".1f"), "1023.0B"), # hundreds number (small formatting boundary) - ((1024, False, True, ".3f", ".1f"), "1.000K"), # hundreds number (small formatting boundary) - ((1023, True, False, ".3f", ".1f"), "1023.0 Bytes"), # hundreds number (small formatting boundary) - ((1024, True, False, ".3f", ".1f"), "1.000 KiB"), # hundreds number (small formatting boundary) + ( + (999, False, False, ".3f", ".1f"), + "999.0 Bytes", + ), # hundreds number (small formatting) + ( + (1000, False, False, ".3f", ".1f"), + "1.000 KB", + ), # hundreds number (small formatting boundary) + ( + (1023, False, True, ".3f", ".1f"), + "1023.0B", + ), # hundreds number (small formatting boundary) + ( + (1024, False, True, ".3f", ".1f"), + "1.000K", + ), # hundreds number (small formatting boundary) + ( + (1023, True, False, ".3f", ".1f"), + "1023.0 Bytes", + ), # hundreds number (small formatting boundary) + ( + (1024, True, False, ".3f", ".1f"), + "1.000 KiB", + ), # hundreds number (small formatting boundary) ((2900000, False, True, ".3f"), "2.766M"), # millions number (large formatting) ( (2000000000, True, False, ".3f"), diff --git a/tests/unit/test_i18n.py b/tests/unit/test_i18n.py index 19d257c..a5b1a69 100644 --- a/tests/unit/test_i18n.py +++ b/tests/unit/test_i18n.py @@ -1,4 +1,5 @@ """Tests for i18n.""" + import pytest import human_readable.i18n as i18n diff --git a/tests/unit/test_lists.py b/tests/unit/test_lists.py index fdf79b5..874cb46 100644 --- a/tests/unit/test_lists.py +++ b/tests/unit/test_lists.py @@ -1,4 +1,5 @@ """Tests for listing humanization.""" + from __future__ import annotations import pytest diff --git a/tests/unit/test_numbers.py b/tests/unit/test_numbers.py index 7b63add..9251516 100644 --- a/tests/unit/test_numbers.py +++ b/tests/unit/test_numbers.py @@ -1,4 +1,5 @@ """Tests for numbers humanizing.""" + from __future__ import annotations import pytest diff --git a/tests/unit/test_times.py b/tests/unit/test_times.py index dae5650..6d7d0cf 100644 --- a/tests/unit/test_times.py +++ b/tests/unit/test_times.py @@ -1,4 +1,5 @@ """Tests for time humanizing.""" + from __future__ import annotations import datetime as dt