Skip to content

Commit bb369f7

Browse files
committed
Add pyupgrade and autoflake8
1 parent 5859602 commit bb369f7

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ repos:
3434
- id: mypy
3535
additional_dependencies:
3636
- zigpy==0.43.0
37+
38+
- repo: https://github.com/asottile/pyupgrade
39+
rev: v2.31.0
40+
hooks:
41+
- id: pyupgrade
42+
43+
- repo: https://github.com/fsouza/autoflake8
44+
rev: v0.3.1
45+
hooks:
46+
- id: autoflake8

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ disable_error_code = [
5353
[tool.coverage.run]
5454
source = "zigpy_znp"
5555

56+
[tool.pyupgrade]
57+
py37plus = true
58+
5659
[tool.tox]
5760
legacy_tox_ini = """
5861
[tox]

tests/application/test_connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def test_leak_detection(make_znp_server, mocker):
2727
znp_server = make_znp_server(server_cls=FormedLaunchpadCC26X2R1)
2828

2929
def count_connected():
30-
return sum([t._is_connected for t in znp_server._transports])
30+
return sum(t._is_connected for t in znp_server._transports)
3131

3232
# Opening and closing one connection will keep the count at zero
3333
assert count_connected() == 0

zigpy_znp/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ def connection_made(self) -> None:
591591
"""
592592
Called by the UART object when a connection has been made.
593593
"""
594-
pass
595594

596595
def connection_lost(self, exc) -> None:
597596
"""

zigpy_znp/types/basic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class TrailingBytes(Bytes):
2929
Bytes must occur at the very end of a parameter list for easy parsing.
3030
"""
3131

32-
pass
33-
3432

3533
def serialize_list(objects) -> Bytes:
3634
return Bytes(b"".join([o.serialize() for o in objects]))

zigpy_znp/types/commands.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CommandHeader(t.uint16_t):
9393

9494
def __new__(
9595
cls, value: int = 0x0000, *, id=None, subsystem=None, type=None
96-
) -> "CommandHeader":
96+
) -> CommandHeader:
9797
instance = super().__new__(cls, value)
9898

9999
if id is not None:
@@ -116,7 +116,7 @@ def id(self) -> t.uint8_t:
116116
"""Return CommandHeader id."""
117117
return t.uint8_t(self >> 8)
118118

119-
def with_id(self, value: int) -> "CommandHeader":
119+
def with_id(self, value: int) -> CommandHeader:
120120
"""command ID setter."""
121121
return type(self)(self & 0x00FF | (value & 0xFF) << 8)
122122

@@ -125,15 +125,15 @@ def subsystem(self) -> Subsystem:
125125
"""Return subsystem of the command."""
126126
return Subsystem(self.cmd0 & 0x1F)
127127

128-
def with_subsystem(self, value: Subsystem) -> "CommandHeader":
128+
def with_subsystem(self, value: Subsystem) -> CommandHeader:
129129
return type(self)(self & 0xFFE0 | value & 0x1F)
130130

131131
@property
132132
def type(self) -> CommandType:
133133
"""Return command type."""
134134
return CommandType(self.cmd0 >> 5)
135135

136-
def with_type(self, value) -> "CommandHeader":
136+
def with_type(self, value) -> CommandHeader:
137137
return type(self)(self & 0xFF1F | (value & 0x07) << 5)
138138

139139
def __str__(self) -> str:
@@ -399,7 +399,7 @@ def to_frame(self, *, align=False):
399399
return GeneralFrame(self.header, b"".join(chunks))
400400

401401
@classmethod
402-
def from_frame(cls, frame, *, align=False) -> "CommandBase":
402+
def from_frame(cls, frame, *, align=False) -> CommandBase:
403403
if frame.header != cls.header:
404404
raise ValueError(
405405
f"Wrong frame header in {cls}: {cls.header} != {frame.header}"
@@ -435,7 +435,7 @@ def from_frame(cls, frame, *, align=False) -> "CommandBase":
435435

436436
return cls(**params)
437437

438-
def matches(self, other: "CommandBase") -> bool:
438+
def matches(self, other: CommandBase) -> bool:
439439
if type(self) is not type(other):
440440
return False
441441

@@ -455,7 +455,7 @@ def matches(self, other: "CommandBase") -> bool:
455455

456456
return True
457457

458-
def replace(self, **kwargs) -> "CommandBase":
458+
def replace(self, **kwargs) -> CommandBase:
459459
"""
460460
Returns a copy of the current command with replaced parameters.
461461
"""

zigpy_znp/types/named.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ def __repr__(self) -> str:
9696
class GroupId(basic.uint16_t, hex_repr=True):
9797
"""Group ID class"""
9898

99-
pass
100-
10199

102100
class ScanType(basic.enum_uint8):
103101
EnergyDetect = 0x00

zigpy_znp/zigbee/application.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ async def permit_ncp(self, time_s: int) -> None:
536536
"""
537537

538538
# Z-Stack does not need any special code to do this
539-
pass
540539

541540
async def permit_with_key(self, node: t.EUI64, code: bytes, time_s=60):
542541
"""
@@ -641,8 +640,6 @@ def on_intentionally_unhandled_message(self, msg: t.CommandBase) -> None:
641640
reduce unnecessary logging messages, they are given an explicit callback.
642641
"""
643642

644-
pass
645-
646643
async def on_zdo_message(self, msg: c.ZDO.MsgCbIncoming.Callback) -> None:
647644
"""
648645
Global callback for all ZDO messages.

0 commit comments

Comments
 (0)