Skip to content

Migrate to black 20.8b1 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2020
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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 20.8b1
hooks:
- id: black
args:
Expand Down
12 changes: 10 additions & 2 deletions tests/application/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ async def test_zigpy_request(device, make_application):
),
responses=[
c.AF.DataRequestExt.Rsp(Status=t.Status.SUCCESS),
c.AF.DataConfirm.Callback(Status=t.Status.SUCCESS, Endpoint=1, TSN=TSN,),
c.AF.DataConfirm.Callback(
Status=t.Status.SUCCESS,
Endpoint=1,
TSN=TSN,
),
c.ZDO.SrcRtgInd.Callback(DstAddr=device.nwk, Relays=[]),
c.AF.IncomingMsg.Callback(
GroupId=0x0000,
Expand Down Expand Up @@ -149,7 +153,11 @@ async def test_zigpy_request_failure(device, make_application, mocker):
),
responses=[
c.AF.DataRequestExt.Rsp(Status=t.Status.SUCCESS),
c.AF.DataConfirm.Callback(Status=t.Status.FAILURE, Endpoint=1, TSN=TSN,),
c.AF.DataConfirm.Callback(
Status=t.Status.FAILURE,
Endpoint=1,
TSN=TSN,
),
],
)

Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def __init__(self, *args, **kwargs):

for req in getattr(func, "_reply_to", []):
self.reply_to(
request=req, responses=[func],
request=req,
responses=[func],
)

def _unhandled_command(self, command):
Expand Down
6 changes: 5 additions & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ def test_command_param_binding():
def test_command_optional_params():
# Optional params values don't need a value
short_version_rsp = c.SYS.Version.Rsp(
TransportRev=0, ProductId=1, MajorRel=2, MinorRel=3, MaintRel=4,
TransportRev=0,
ProductId=1,
MajorRel=2,
MinorRel=3,
MaintRel=4,
)

# Some can still be passed
Expand Down
5 changes: 4 additions & 1 deletion tests/tools/test_energy_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ async def response(request):

znp_server.callback_for_response(
c.ZDO.MgmtNWKUpdateReq.Req(
Dst=0x0000, DstAddrMode=t.AddrMode.NWK, NwkManagerAddr=0x0000, partial=True,
Dst=0x0000,
DstAddrMode=t.AddrMode.NWK,
NwkManagerAddr=0x0000,
partial=True,
),
fake_scanner,
)
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ deps = flake8
commands = flake8

[testenv:black]
deps=black
deps =
black==20.8.b1
setenv =
LC_ALL=C.UTF-8
LANG=C.UTF-8
Expand Down
7 changes: 5 additions & 2 deletions zigpy_znp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ async def nvram_write(self, nv_id: nvids.BaseNvIds, value, *, create: bool = Fal

await self.request(
c.SYS.OSALNVItemInit.Req(
Id=nv_id, ItemLen=len(value), Value=t.ShortBytes(value[:244]),
Id=nv_id,
ItemLen=len(value),
Value=t.ShortBytes(value[:244]),
),
RspStatus=t.Status.NV_ITEM_UNINIT,
)
Expand All @@ -641,7 +643,8 @@ async def nvram_read(self, nv_id: nvids.BaseNvIds) -> bytes:
# XXX: Some NVIDs don't really exist and Z-Stack behaves strangely with them
if nv_id == t.nvids.NwkNvIds.POLL_RATE_OLD16:
read_rsp = await self.request(
c.SYS.OSALNVRead.Req(Id=nv_id, Offset=0), RspStatus=t.Status.SUCCESS,
c.SYS.OSALNVRead.Req(Id=nv_id, Offset=0),
RspStatus=t.Status.SUCCESS,
)

return read_rsp.Value
Expand Down
8 changes: 6 additions & 2 deletions zigpy_znp/commands/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class App(t.CommandsBase, subsystem=t.Subsystem.APP):
0x00,
req_schema=(
t.Param(
"Endpoint", t.uint8_t, "Application endpoint of the outgoing message",
"Endpoint",
t.uint8_t,
"Application endpoint of the outgoing message",
),
t.Param("DstAddr", t.NWK, "Destination address of the outgoing message"),
t.Param(
Expand All @@ -31,7 +33,9 @@ class App(t.CommandsBase, subsystem=t.Subsystem.APP):
0x01,
req_schema=(
t.Param(
"SrcEndpoint", t.uint8_t, "Source Endpoint of the user-defined command",
"SrcEndpoint",
t.uint8_t,
"Source Endpoint of the user-defined command",
),
t.Param("CommandId", t.uint16_t, "Command Id of the user-defined command"),
t.Param("Parameter1", t.uint16_t, "Parameter #1 of the command"),
Expand Down
4 changes: 3 additions & 1 deletion zigpy_znp/commands/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ class AppConfig(t.CommandsBase, subsystem=t.Subsystem.APPConfig):
0x03,
req_schema=(
t.Param(
"AllowRejoin", t.Bool, "whether or not the Trust center allows rejoins",
"AllowRejoin",
t.Bool,
"whether or not the Trust center allows rejoins",
),
),
rsp_schema=t.STATUS_SCHEMA,
Expand Down
28 changes: 21 additions & 7 deletions zigpy_znp/commands/mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class MAC(t.CommandsBase, subsystem=t.Subsystem.MAC):
0x01,
req_schema=(
t.Param(
"SetDefault", t.Bool, "TRUE - Set the MAC pib values to default values",
"SetDefault",
t.Bool,
"TRUE - Set the MAC pib values to default values",
),
),
rsp_schema=t.STATUS_SCHEMA,
Expand Down Expand Up @@ -70,15 +72,19 @@ class MAC(t.CommandsBase, subsystem=t.Subsystem.MAC):
t.Param("RealignKeySource", t.KeySource, "Key Source of this data frame"),
# ToDo: Enum for for RealignSecurityLevel
t.Param(
"RealignSecurityLevel", t.uint8_t, "Security level of this data frame",
"RealignSecurityLevel",
t.uint8_t,
"Security level of this data frame",
),
# ToDo: Make this an enum
t.Param("RealignKeyIdMode", t.uint8_t, "Key Id Mode of this frame"),
t.Param("RealignKeyIndex", t.uint8_t, "Key index of this frame"),
t.Param("BeaconKeySource", t.KeySource, "Key source of this data frame"),
# ToDo: Make this an enum
t.Param(
"BeaconSecurityLevel", t.uint8_t, "Security Level of this data frame",
"BeaconSecurityLevel",
t.uint8_t,
"Security Level of this data frame",
),
t.Param("BeaconKeyIdMode", t.uint8_t, "Key Id Mode of this data frame"),
t.Param("BeaconKeyIndex", t.uint8_t, "Key index of this data frame"),
Expand Down Expand Up @@ -270,7 +276,9 @@ class MAC(t.CommandsBase, subsystem=t.Subsystem.MAC):
),
t.Param("NWK", t.NWK, "Short address of the associated device"),
t.Param(
"AssociatedMember", t.Bool, "True is the orphan is a associated member",
"AssociatedMember",
t.Bool,
"True is the orphan is a associated member",
),
),
rsp_schema=t.STATUS_SCHEMA,
Expand Down Expand Up @@ -323,7 +331,9 @@ class MAC(t.CommandsBase, subsystem=t.Subsystem.MAC):
rsp_schema=(
t.Param("Status", t.Status, "Status is either Success (0) or Failure (1)"),
t.Param(
"PanId", t.PanId, "The PAN Id to use. This parameter is ignored if Pan",
"PanId",
t.PanId,
"The PAN Id to use. This parameter is ignored if Pan",
),
t.Param("LogicalChannel", t.uint8_t, "The logical channel to use"),
t.Param("ChannelPage", t.uint8_t, "The channel page to use"),
Expand Down Expand Up @@ -381,7 +391,9 @@ class MAC(t.CommandsBase, subsystem=t.Subsystem.MAC):
"Extended address of coordinator",
),
t.Param(
"PanId", t.PanId, "The PAN Id to use. This parameter is ignored if Pan",
"PanId",
t.PanId,
"The PAN Id to use. This parameter is ignored if Pan",
),
t.Param("Superframe", t.uint16_t, "Superframe specification"),
t.Param("LogicalChannel", t.uint8_t, "The logical channel to use"),
Expand All @@ -396,7 +408,9 @@ class MAC(t.CommandsBase, subsystem=t.Subsystem.MAC):
t.Param("KeyIndex", t.uint8_t, "Key index of this frame"),
t.Param("PendingAddrSpec", t.uint8_t, "Pending address spec"),
t.Param(
"AddressList", t.uint8_t, "List of address associate with the device",
"AddressList",
t.uint8_t,
"List of address associate with the device",
),
t.Param("NSDU", t.ShortBytes, "Beacon payload"),
),
Expand Down
8 changes: 6 additions & 2 deletions zigpy_znp/commands/sapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class SAPI(t.CommandsBase, subsystem=t.Subsystem.SAPI):
t.Param("Destination", t.NWK, "Short address of the destination"),
t.Param("CommandId", t.uint16_t, "The command id to send with the message"),
t.Param(
"Handle", t.uint8_t, "A handle used to Identify the send data request",
"Handle",
t.uint8_t,
"A handle used to Identify the send data request",
),
t.Param("Ack", t.Bool, "True if requesting ACK from the destination"),
t.Param(
Expand Down Expand Up @@ -163,7 +165,9 @@ class SAPI(t.CommandsBase, subsystem=t.Subsystem.SAPI):
0x83,
rsp_schema=(
t.Param(
"Handle", t.uint8_t, "A handle used to Identify the send data request",
"Handle",
t.uint8_t,
"A handle used to Identify the send data request",
),
t.Param("Status", t.Status, "Status is either Success (0) or Failure (1)"),
),
Expand Down
8 changes: 6 additions & 2 deletions zigpy_znp/commands/sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ class SYS(t.CommandsBase, subsystem=t.Subsystem.SYS):
0x10,
req_schema=(
t.Param(
"UTCTime", t.uint32_t, "Number of seconds since 00:00:00 on Jan 2000",
"UTCTime",
t.uint32_t,
"Number of seconds since 00:00:00 on Jan 2000",
),
t.Param("Hour", t.uint8_t, "Hour of the day (0 -- 23)"),
t.Param("Minute", t.uint8_t, "Minute of the hour (0 -- 59)"),
Expand All @@ -326,7 +328,9 @@ class SYS(t.CommandsBase, subsystem=t.Subsystem.SYS):
req_schema=(),
rsp_schema=(
t.Param(
"UTCTime", t.uint32_t, "Number of seconds since 00:00:00 on Jan 2000",
"UTCTime",
t.uint32_t,
"Number of seconds since 00:00:00 on Jan 2000",
),
t.Param("Hour", t.uint8_t, "Hour of the day (0 -- 23)"),
t.Param("Minute", t.uint8_t, "Minute of the hour (0 -- 59)"),
Expand Down
16 changes: 12 additions & 4 deletions zigpy_znp/commands/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ class Util(t.CommandsBase, subsystem=t.Subsystem.UTIL):
"Channels to be scanned when starting the device. Big endian!",
),
t.Param(
"PanId", t.PanId, "The PAN Id to use. This parameter is ignored if Pan",
"PanId",
t.PanId,
"The PAN Id to use. This parameter is ignored if Pan",
),
# ToDo: Make this an enum
t.Param("SecurityLevel", t.uint8_t, "Security level of this data frame"),
Expand Down Expand Up @@ -233,7 +235,9 @@ class Util(t.CommandsBase, subsystem=t.Subsystem.UTIL):
req_schema=(
t.Param("AddrModeAddress", t.AddrModeAddress, "Address mode and address"),
t.Param(
"PanId", t.PanId, "PAN Id of the device. Only use with a short address",
"PanId",
t.PanId,
"PAN Id of the device. Only use with a short address",
),
),
rsp_schema=t.STATUS_SCHEMA,
Expand All @@ -246,7 +250,9 @@ class Util(t.CommandsBase, subsystem=t.Subsystem.UTIL):
req_schema=(
t.Param("AddrModeAddress", t.AddrModeAddress, "Address mode and address"),
t.Param(
"PanId", t.PanId, "PAN Id of the device. Only use with a short address",
"PanId",
t.PanId,
"PAN Id of the device. Only use with a short address",
),
),
rsp_schema=t.STATUS_SCHEMA,
Expand All @@ -259,7 +265,9 @@ class Util(t.CommandsBase, subsystem=t.Subsystem.UTIL):
req_schema=(
t.Param("AddrModeAddress", t.AddrModeAddress, "Address mode and address"),
t.Param(
"PanId", t.PanId, "PAN Id of the device. Only use with a short address",
"PanId",
t.PanId,
"PAN Id of the device. Only use with a short address",
),
),
rsp_schema=t.STATUS_SCHEMA,
Expand Down
Loading