Skip to content
Closed
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
95 changes: 38 additions & 57 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

from datetime import datetime


Expand Down
1 change: 1 addition & 0 deletions src/human_readable/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions src/human_readable/i18n.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Activate, get and deactivate translations."""

from __future__ import annotations

import gettext as gettext_module
Expand Down
1 change: 1 addition & 0 deletions src/human_readable/lists.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for lists humanization."""

from __future__ import annotations


Expand Down
1 change: 1 addition & 0 deletions src/human_readable/numbers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Humanizing functions for numbers."""

from __future__ import annotations

import fractions
Expand Down
1 change: 1 addition & 0 deletions src/human_readable/times.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Time humanizing functions."""

from __future__ import annotations

import datetime as dt
Expand Down
1 change: 1 addition & 0 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixtures for functional tests."""

import pytest
from pytest_mock import MockerFixture

Expand Down
1 change: 1 addition & 0 deletions tests/functional/en_ABBR/test_numbers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for ru_RU numbers humanizing."""

from pytest_mock import MockerFixture

import human_readable
Expand Down
1 change: 1 addition & 0 deletions tests/functional/en_ABBR/test_times.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for time humanizing."""

import datetime as dt

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/functional/fr_FR/test_numbers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for fr_FR numbers humanizing."""

from pytest_mock import MockerFixture

import human_readable.numbers as numbers
Expand Down
1 change: 1 addition & 0 deletions tests/functional/pt_BR/test_numbers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for pt_BR numbers humanizing."""

import pytest
from pytest_mock import MockerFixture

Expand Down
1 change: 1 addition & 0 deletions tests/functional/pt_BR/test_times.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for pt_BR time humanizing."""

from __future__ import annotations

import datetime as dt
Expand Down
1 change: 1 addition & 0 deletions tests/functional/ru_RU/test_numbers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for ru_RU numbers humanizing."""

from pytest_mock import MockerFixture

import human_readable.numbers as numbers
Expand Down
1 change: 1 addition & 0 deletions tests/functional/ru_RU/test_times.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for time humanizing."""

import datetime as dt

from pytest_mock import MockerFixture
Expand Down
31 changes: 25 additions & 6 deletions tests/unit/test_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for file size humanization."""

from __future__ import annotations

import pytest
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_i18n.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for i18n."""

import pytest

import human_readable.i18n as i18n
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_lists.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for listing humanization."""

from __future__ import annotations

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_numbers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for numbers humanizing."""

from __future__ import annotations

import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_times.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for time humanizing."""

from __future__ import annotations

import datetime as dt
Expand Down
Loading