From b1c859a08af77a22a7ed571534119154cae95fb2 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 11 Mar 2023 17:57:56 +0100 Subject: [PATCH] Enable tryceratops rules --- pyproject.toml | 2 ++ src/biip/gtin/_rcn.py | 2 +- src/biip/upc.py | 12 +++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fe53432..12cbf32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,6 +122,7 @@ select = [ "T20", # flake8-print "TCH", # flake8-type-checking "TID", # flake8-tidy-imports + "TRY", # tryceratops "UP", # pyupgrade "W", # pycodestyle ] @@ -131,6 +132,7 @@ ignore = [ "ANN102", # missing-type-cls "PLR2004", # magic-value-comparison "RET504", # unnecessary-assign + "TRY003", # raise-vanilla-args # # Equivalent to `pyupgrade --keep-runtime-typing`: "UP006", # deprecated-collection-type diff --git a/src/biip/gtin/_rcn.py b/src/biip/gtin/_rcn.py index 4165a6f..088aa2f 100644 --- a/src/biip/gtin/_rcn.py +++ b/src/biip/gtin/_rcn.py @@ -168,7 +168,7 @@ def get_for_rcn(cls, rcn: Rcn) -> Optional[_Strategy]: region_rules = _RCN_RULES.get(rcn.region) if region_rules is None: - raise Exception( # pragma: no cover + raise Exception( # noqa: TRY002 # pragma: no cover "RCN region defined without defining rules. This is a bug." ) diff --git a/src/biip/upc.py b/src/biip/upc.py index 586ab7d..7c596d9 100644 --- a/src/biip/upc.py +++ b/src/biip/upc.py @@ -125,7 +125,9 @@ def parse(cls, value: str) -> Upc: if length in (6, 7, 8): return cls._parse_upc_e(value) - raise Exception("Unhandled UPC length. This is a bug.") # pragma: no cover + raise Exception( # noqa: TRY002 # pragma: no cover + "Unhandled UPC length. This is a bug." + ) @classmethod def _parse_upc_a(cls, value: str) -> Upc: @@ -173,7 +175,7 @@ def _parse_upc_e(cls, value: str) -> Upc: payload = value[:-1] check_digit = int(value[-1]) else: - raise Exception( # pragma: no cover + raise Exception( # noqa: TRY002 # pragma: no cover "Unhandled UPC-E length. This is a bug." ) @@ -216,7 +218,7 @@ def as_upc_a(self) -> str: if self.format == UpcFormat.UPC_E: return _upc_e_to_upc_a_expansion(f"{self.payload}{self.check_digit}") - raise Exception( # pragma: no cover + raise Exception( # noqa: TRY002 # pragma: no cover "Unhandled case while formatting as UPC-A. This is a bug." ) @@ -238,7 +240,7 @@ def as_upc_e(self) -> str: if self.format == UpcFormat.UPC_E: return f"{self.payload}{self.check_digit}" - raise Exception( # pragma: no cover + raise Exception( # noqa: TRY002 # pragma: no cover "Unhandled case while formatting as UPC-E. This is a bug." ) @@ -280,7 +282,7 @@ def _upc_e_to_upc_a_expansion(value: str) -> str: if last_digit in (5, 6, 7, 8, 9): return f"{value[:6]}0000{last_digit}{check_digit}" - raise Exception( # pragma: no cover + raise Exception( # noqa: TRY002 # pragma: no cover "Unhandled case while expanding UPC-E to UPC-A. This is a bug." )