Skip to content
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: 1 addition & 1 deletion local/tests/test_collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def is_histogram_evenly_distributed(
return all(min_bin_size < count < max_bin_size for count in histogram_values)


@pytest.mark.slow()
@pytest.mark.slow
@pytest.mark.parametrize(
("num_ids", "num_pools"),
[
Expand Down
4 changes: 2 additions & 2 deletions local/tests/test_cuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class TestCuid:
# Tests execution time to ensure that time complexity doesn't increase.
@pytest.mark.slow()
@pytest.mark.slow
def test_generate_performance(self: "TestCuid") -> None:
timing_result = repeat(
stmt="cuid.generate()",
Expand Down Expand Up @@ -41,7 +41,7 @@ def test_generate_length_none(self: "TestCuid") -> None:

# Tests that generate() works when length parameter is really long.
def test_generate_really_long_length(self: "TestCuid") -> None:
with pytest.raises(ValueError, match="Length must never exceed 98 characters."):
with pytest.raises(ValueError, match=r"Length must never exceed 98 characters\."):
Cuid(length=100)

# Tests that generate() works when length parameter is less than 2.
Expand Down
8 changes: 4 additions & 4 deletions local/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_zero_returns_0(self: "TestBase36Encode") -> None:

# Tests that the function raises a ValueError when given a negative number
def test_negative_number_raises_value_error(self: "TestBase36Encode") -> None:
with pytest.raises(ValueError, match="Cannot encode negative integers."):
with pytest.raises(ValueError, match=r"Cannot encode negative integers\."):
utils.base36_encode(-1)

# Tests that the function can handle the maximum value for an integer
Expand Down Expand Up @@ -143,15 +143,15 @@ def test_create_entropy_zero_length(self: "TestCreateEntropy", mocker: "Mock") -
# Edge case test with length = 0
mock_random = mocker.Mock()
mock_random.random.return_value = 0.5
with pytest.raises(ValueError, match="Cannot create entropy without a length >= 1."):
with pytest.raises(ValueError, match=r"Cannot create entropy without a length >= 1\."):
utils.create_entropy(mock_random, length=0)

# Tests that create_entropy raises a ValueError when given a valid instance of Random and a negative length
def test_create_entropy_negative_length(self: "TestCreateEntropy", mocker: "Mock") -> None:
# Edge case test with negative length
mock_random = mocker.Mock()
mock_random.random.return_value = 0.5
with pytest.raises(ValueError, match="Cannot create entropy without a length >= 1."):
with pytest.raises(ValueError, match=r"Cannot create entropy without a length >= 1\."):
utils.create_entropy(mock_random, length=-1)

# Tests that create_entropy raises a TypeError when given an invalid instance of Random
Expand Down Expand Up @@ -278,7 +278,7 @@ def test_create_entropy_with_invalid_length(self: "TestCreateFingerprint", mocke
mock_random.random.return_value = 0.5
invalid_length = -1

with pytest.raises(ValueError, match="Cannot create entropy without a length >= 1."):
with pytest.raises(ValueError, match=r"Cannot create entropy without a length >= 1\."):
utils.create_entropy(random_generator=mock_random, length=invalid_length)

# Tests that create_fingerprint returns a string of length BIG_LENGTH even when the entropy
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ default-groups = ["lint", "test", "tox", "typing"]
lint = [
"codespell==2.4.3", # https://github.com/codespell-project/codespell (latest: 2.2.6)
"pylint==4.0.8", # https://github.com/pylint-dev/pylint (latest: 3.1.0)
"requests==2.34.2", # https://github.com/psf/requests (latest: 2.31.0)
"ruff==0.16.6", # https://github.com/astral-sh/ruff (latest: 0.3.7)
"safety==3.8.1", # https://github.com/pyupio/safety (latest: 3.8.1)
]
test = [
"pytest==9.1.1", # https://github.com/pytest-dev/pytest (latest: 9.1.1)
Expand Down Expand Up @@ -79,12 +77,11 @@ legacy_tox_ini = """
typing
test
commands =
ruff check --fix --exit-zero src/ local/tests/
ruff check --fix src/ local/tests/
ruff format src/ local/tests/
codespell src/ local/tests/
pylint src/ local/tests/
mypy src/ local/tests/
safety check --bare
"""

[tool.ruff]
Expand All @@ -98,7 +95,7 @@ force-exclude = true
# https://docs.astral.sh/ruff/rules/
select = [
"F", "E", "W", "C90", "I", "N", "ASYNC",
"TRIO", "S", "BLE", "B", "A", "COM", "C4",
"S", "BLE", "B", "A", "COM", "C4",
"DTZ", "T10", "EM", "FA", "ISC", "ICN",
"G", "INP", "PIE", "T20", "PT", "Q", "RSE",
"RET", "SLF", "SLOT", "SIM", "INT", "ARG",
Expand Down
2 changes: 1 addition & 1 deletion src/cuid2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from .generator import DEFAULT_LENGTH, INITIAL_COUNT_MAX, Cuid, cuid_wrapper

__all__ = ["Cuid", "DEFAULT_LENGTH", "INITIAL_COUNT_MAX", "cuid_wrapper"]
__all__ = ["DEFAULT_LENGTH", "INITIAL_COUNT_MAX", "Cuid", "cuid_wrapper"]
3 changes: 1 addition & 2 deletions src/cuid2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@


if TYPE_CHECKING:
from hashlib import _Hash

from _random import Random
from hashlib import _Hash


def create_counter(count: int) -> Callable[[], int]:
Expand Down
Loading
Loading