Skip to content

Commit

Permalink
Enable tryceratops rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Mar 11, 2023
1 parent aaa3def commit b1c859a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ select = [
"T20", # flake8-print
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/biip/gtin/_rcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)

Expand Down
12 changes: 7 additions & 5 deletions src/biip/upc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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."
)

Expand Down Expand Up @@ -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."
)

Expand All @@ -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."
)

Expand Down Expand Up @@ -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."
)

Expand Down

0 comments on commit b1c859a

Please sign in to comment.