Skip to content
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: zigpy/workflows/.github/workflows/ci.yml@main
with:
CODE_FOLDER: zigpy_znp
CACHE_VERSION: 2
CACHE_VERSION: 3
MINIMUM_COVERAGE_PERCENTAGE: 95
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/matchers/codespell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "codespell",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):(\\d+):\\s(.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
30 changes: 0 additions & 30 deletions .github/workflows/matchers/flake8.json

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/matchers/ruff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"problemMatcher": [
{
"owner": "ruff-error",
"severity": "error",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s([EF]\\d{3}\\s.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
},
{
"owner": "ruff-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s([CDNW]\\d{3}\\s.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ ENV/

TI Z-Stack/

zigpy-znp-*.*.*/
zigpy-znp-*.*.*/
uv.lock
51 changes: 14 additions & 37 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
- id: debug-statements
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix", "--config", "pyproject.toml"]
- id: ruff-format
args: ["--config", "pyproject.toml"]

- repo: https://github.com/psf/black
rev: 23.10.1
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
entry: pflake8
additional_dependencies:
- pyproject-flake8==7.0.0
- flake8-bugbear==24.2.6
- flake8-comprehensions==3.14.0
- flake8_2020==1.8.1
- mccabe==0.7.0
- pycodestyle==2.11.1
- pyflakes==3.2.0

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- id: codespell
additional_dependencies: [tomli]
args: ["--toml", "pyproject.toml"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
rev: v2.3.1
hooks:
- id: mypy
additional_dependencies:
- zigpy>=0.91.2
- zigpy>=1.5.0
- types-setuptools

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade

- repo: https://github.com/fsouza/autoflake8
rev: v0.4.1
hooks:
- id: autoflake8
exclude: ^tests/
100 changes: 67 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,26 @@ dependencies = [
[tool.setuptools.packages.find]
exclude = ["tests", "tests.*"]

[project.optional-dependencies]
[dependency-groups]
testing = [
"mypy==2.3.1",
"pre-commit",
"coverage[toml]",
"pytest>=7.3.1",
"pytest-asyncio>=0.21.0",
"pytest-timeout>=2.1.0",
"pytest-mock>=3.10.0",
"pytest-cov>=4.1.0",
"pytest-mock>=3.10.0",
"pytest-timeout>=2.1.0",
]
ci = [
{include-group = "testing"},
"pytest-github-actions-annotate-failures",
"pytest-xdist",
]

[tool.setuptools-git-versioning]
enabled = true


[tool.black]
safe = true
quiet = true

[tool.isort]
multi_line_output = 3
length_sort = true
balanced_wrapping = true
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 88
indent = " "
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
default_section = "THIRDPARTY"
known_first_party = ["zigpy_znp", "tests"]
forced_separate = "tests"
combine_as_imports = true

[tool.pytest.ini_options]
addopts = "--showlocals --verbose"
testpaths = ["tests"]
Expand All @@ -64,19 +52,59 @@ log_date_format = "%Y-%m-%d %H:%M:%S"
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"

[tool.flake8]
exclude = ".venv,.git,.tox,docs,venv,bin,lib,deps,build"
# To work with Black
max-line-length = 88
# W503: Line break occurred before a binary operator
# E203: Whitespace before ':'
# D202 No blank lines allowed after function docstring
ignore = "W503,E203,D202"
[tool.ruff]
required-version = ">=0.5.0"
target-version = "py311"
line-length = 88

exclude = [
".venv",
".git",
".tox",
"docs",
"venv",
"bin",
"lib",
"deps",
"build",
]

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C", # complexity
"E", # pycodestyle
"F", # pyflakes/autoflake
"I", # isort
"SIM", # flake8-simplify
"UP", # pyupgrade
"W", # pycodestyle
]

[tool.ruff.lint.mccabe]
max-complexity = 25

[tool.ruff.lint.isort]
force-sort-within-sections = true
known-first-party = [
"zigpy_znp",
"tests",
]
forced-separate = ["tests"]
combine-as-imports = true
split-on-trailing-comma = false

[tool.codespell]
skip = ["./.*", "tests/*", "pyproject.toml"]
quiet-level = 2

[tool.mypy]
ignore_missing_imports = true
check_untyped_defs = true
show_error_codes = true
show_error_context = true
error_summary = true
exclude = ["^tests/"]
disable_error_code = [
"attr-defined",
"assignment",
Expand All @@ -95,5 +123,11 @@ disable_error_code = [
[tool.coverage.run]
source = ["zigpy_znp"]

[tool.pyupgrade]
py311plus = true
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
"if typing.TYPE_CHECKING:",
"raise NotImplementedError",
"raise NotImplementedError()",
]
5 changes: 0 additions & 5 deletions requirements_test.txt

This file was deleted.

4 changes: 2 additions & 2 deletions tests/api/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import pytest

import zigpy_znp.types as t
import zigpy_znp.commands as c
from zigpy_znp.api import ZNP
import zigpy_znp.commands as c
import zigpy_znp.types as t

from ..conftest import BaseServerZNP, CoroutineMock, config_for_port_path

Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import pytest

import zigpy_znp.types as t
from zigpy_znp.api import CallbackResponseListener, OneShotResponseListener
import zigpy_znp.commands as c
from zigpy_znp.api import OneShotResponseListener, CallbackResponseListener
import zigpy_znp.types as t


async def test_resolve(mocker):
Expand Down
10 changes: 5 additions & 5 deletions tests/api/test_network_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import pytest
from zigpy.exceptions import FormationFailure

import zigpy_znp.types as t
import zigpy_znp.commands as c
import zigpy_znp.types as t
from zigpy_znp.types.nvids import ExNvIds, OsalNvIds

from ..conftest import (
ALL_DEVICES,
FORMED_DEVICES,
BaseZStack1CC2531,
FormedZStack3CC2531,
FormedLaunchpadCC26X2R1,
FormedZStack3CC2531,
)


Expand Down Expand Up @@ -64,9 +64,9 @@ async def test_broken_cc2531_load_state(device, make_connected_znp, caplog):
znp, znp_server = await make_connected_znp(server_cls=device)

# "Bad" TCLK seed is a TCLK from Z-Stack 1 with the first 16 bytes overwritten
znp_server._nvram[ExNvIds.LEGACY][
OsalNvIds.TCLK_SEED
] += b"liance092\x00\x00\x00\x00\x00\x00\x00"
znp_server._nvram[ExNvIds.LEGACY][OsalNvIds.TCLK_SEED] += (
b"liance092\x00\x00\x00\x00\x00\x00\x00"
)

caplog.set_level(logging.ERROR)
await znp.load_network_info()
Expand Down
6 changes: 3 additions & 3 deletions tests/api/test_nvram.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest

import zigpy_znp.types as t
import zigpy_znp.commands as c
from zigpy_znp.types import nvids
from zigpy_znp.exceptions import SecurityError
import zigpy_znp.types as t
from zigpy_znp.types import nvids


async def test_osal_writes_invalid(connected_znp):
Expand Down Expand Up @@ -271,7 +271,7 @@ async def test_osal_read_security_bypass(connected_znp, nvid, value):


@pytest.mark.parametrize("nvid", [nvids.OsalNvIds.POLL_RATE_OLD16])
@pytest.mark.parametrize("value", [b"\xAB\xCD"])
@pytest.mark.parametrize("value", [b"\xab\xcd"])
async def test_osal_read_proxied(connected_znp, nvid, value):
znp, znp_server = connected_znp

Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_nvram_migration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

import zigpy_znp.commands as c
import zigpy_znp.const as const
import zigpy_znp.types as t
import zigpy_znp.commands as c
from zigpy_znp.types.nvids import ExNvIds, OsalNvIds

from ..conftest import FORMED_DEVICES, FormedZStack3CC2531
Expand Down
Loading