Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bump black to fix the Click dependency issue
  • Loading branch information
puddly committed Mar 30, 2022
1 parent 0c4b9a8 commit fdfe55a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -10,7 +10,7 @@ repos:
- id: autoflake8

- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
args:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_types.py
Expand Up @@ -106,24 +106,24 @@ class int7s(t.int_t, bits=7):
assert int7s(0) == 0
assert int7s(1) == 1
assert int7s(-1) == -1
assert int7s(2 ** 6 - 1) == 2 ** 6 - 1
assert int7s(-(2 ** 6)) == -(2 ** 6)
assert int7s(2**6 - 1) == 2**6 - 1
assert int7s(-(2**6)) == -(2**6)

with pytest.raises(ValueError):
int7s(2 ** 6)
int7s(2**6)

with pytest.raises(ValueError):
int7s(-(2 ** 6) - 1)
int7s(-(2**6) - 1)

n = int7s(2 ** 6 - 1)
n = int7s(2**6 - 1)

with pytest.raises(TypeError):
n.serialize()

assert int7s(0).bits() == [0, 0, 0, 0, 0, 0, 0]
assert int7s(1).bits() == [0, 0, 0, 0, 0, 0, 1]
assert int7s(-1).bits() == [1, 1, 1, 1, 1, 1, 1]
assert int7s(2 ** 6 - 1).bits() == [0, 1, 1, 1, 1, 1, 1]
assert int7s(2**6 - 1).bits() == [0, 1, 1, 1, 1, 1, 1]

assert int7s.from_bits([1, 0, 1, 0, 1, 1, 0, 1, 1, 1]) == (0b0110111, [1, 0, 1])

Expand Down
6 changes: 3 additions & 3 deletions zigpy/types/basic.py
Expand Up @@ -60,7 +60,7 @@ def __new__(cls, *args, **kwargs):

n = super().__new__(cls, *args, **kwargs)

if not cls._signed and not 0 <= n <= 2 ** cls._bits - 1:
if not cls._signed and not 0 <= n <= 2**cls._bits - 1:
raise ValueError(f"{int(n)} is not an unsigned {cls._bits} bit integer")
elif (
cls._signed and not -(2 ** (cls._bits - 1)) <= n <= 2 ** (cls._bits - 1) - 1
Expand Down Expand Up @@ -121,7 +121,7 @@ def from_bits(cls, bits: Bits) -> tuple[FixedIntType, Bits]:
n |= bit & 1

if cls._signed and n >= 2 ** (cls._bits - 1):
n -= 2 ** cls._bits
n -= 2**cls._bits

return cls(n), bits[: -cls._bits]

Expand Down Expand Up @@ -418,7 +418,7 @@ def _convert_format(*, src: BaseFloat, dst: BaseFloat, n: int) -> int:
src_exp = src_biased_exp - 2 ** (src._exponent_bits - 1)

if src_biased_exp == (1 << src._exponent_bits) - 1:
dst_biased_exp = 2 ** dst._exponent_bits - 1
dst_biased_exp = 2**dst._exponent_bits - 1
elif src_biased_exp == 0:
dst_biased_exp = 0
else:
Expand Down

0 comments on commit fdfe55a

Please sign in to comment.