Skip to content
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

Initial standalone version #6

Merged
merged 124 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
a431b98
update pyproject.toml
dmulcahey Mar 15, 2024
60dd2bb
add periodic decorator from zhawss
dmulcahey Mar 15, 2024
11e3c94
add deps
dmulcahey Mar 16, 2024
8b284d8
update cluster handlers
dmulcahey Mar 16, 2024
5dcb2c5
update group
dmulcahey Mar 16, 2024
c5e1325
update endpoint
dmulcahey Mar 16, 2024
c8df121
update device
dmulcahey Mar 16, 2024
2ce2edb
cleanup gateway
dmulcahey Mar 16, 2024
51aa09a
more gateway cleanup
dmulcahey Mar 16, 2024
23c70d5
cleanup discovery
dmulcahey Mar 16, 2024
8b8b2a9
cleanup registries
dmulcahey Mar 16, 2024
c07dab2
fix slugify dep
dmulcahey Mar 16, 2024
76ec35e
clean up helpers
dmulcahey Mar 16, 2024
372efb8
clean up
dmulcahey Mar 16, 2024
d15dcc1
rename
dmulcahey Mar 16, 2024
aee7435
start working on entities
dmulcahey Mar 17, 2024
43cc98a
update for quirks stuff
dmulcahey Mar 17, 2024
dae29c6
async stuff
dmulcahey Mar 17, 2024
54cd76e
start updating platform entities
dmulcahey Mar 17, 2024
b663a28
update lock
dmulcahey Mar 17, 2024
99e2654
update number
dmulcahey Mar 17, 2024
dad48ec
update select
dmulcahey Mar 17, 2024
c8beba6
clean up sensor
dmulcahey Mar 17, 2024
46f97e0
update siren
dmulcahey Mar 17, 2024
ff1a0fb
update switch
dmulcahey Mar 17, 2024
073f356
clean up
dmulcahey Mar 17, 2024
5bd2626
remove temp
dmulcahey Mar 17, 2024
f0cd23a
tests from zhaws
dmulcahey Mar 17, 2024
d8bfbd7
button test
dmulcahey Mar 17, 2024
11b66c5
task cleanup
dmulcahey Mar 18, 2024
4fc07d7
binary sensor test cleanup
dmulcahey Mar 18, 2024
44efbea
cluster handlers tests and cleanup
dmulcahey Mar 18, 2024
21ab4c5
discovery fixes
dmulcahey Mar 18, 2024
8472e90
clean up
dmulcahey Mar 18, 2024
62fe955
more cleanup
dmulcahey Mar 18, 2024
26e0e53
cleanup
dmulcahey Mar 18, 2024
4cc2c41
test alarm control panel
dmulcahey Mar 18, 2024
bd197fc
remove import
dmulcahey Mar 18, 2024
527bf53
climate tests
dmulcahey Mar 18, 2024
f640b34
cover tests
dmulcahey Mar 18, 2024
f2bed40
cleanup
dmulcahey Mar 18, 2024
35e92fa
fan tests
dmulcahey Mar 18, 2024
981d68d
lock tests
dmulcahey Mar 18, 2024
02ab3a8
number tests
dmulcahey Mar 18, 2024
e40c8bc
more tests
dmulcahey Mar 18, 2024
0c5ea93
more work on tests
dmulcahey Mar 19, 2024
f33f0e6
restructure and cleanup
dmulcahey Mar 19, 2024
3256a16
more select tests
dmulcahey Mar 19, 2024
ef98cee
switch tests
dmulcahey Mar 19, 2024
74e1231
counter sensor temp fixes
dmulcahey Mar 19, 2024
8c4a678
don't load 2x
dmulcahey Mar 19, 2024
1b339f6
more testing work
dmulcahey Mar 20, 2024
0963e19
more tests
dmulcahey Mar 20, 2024
db695cc
make all tests green
dmulcahey Mar 20, 2024
8054dbf
clean up
dmulcahey Mar 20, 2024
937742d
more cleanup
dmulcahey Mar 20, 2024
51f80d7
absolutify the imports
dmulcahey Mar 20, 2024
14e8f67
rough conversion on update
dmulcahey Mar 20, 2024
f1b91a0
clean up constant duplication
dmulcahey Mar 20, 2024
ecc168f
fix stupid git ignore
dmulcahey Mar 20, 2024
5b6f947
add coverage
dmulcahey Mar 21, 2024
c1990d3
don't count TYPE_CHECKING blocks in coverage
dmulcahey Mar 21, 2024
8185f0c
unwind the sensordeviceclass changes from HA
dmulcahey Mar 21, 2024
e4337c2
more test coverage
dmulcahey Mar 21, 2024
eb1a800
button coverage
dmulcahey Mar 21, 2024
55a1494
coverage
dmulcahey Mar 22, 2024
b2e50c6
fix event handling
dmulcahey Mar 22, 2024
e64099b
coverage
dmulcahey Mar 22, 2024
5691b2a
coverage
dmulcahey Mar 22, 2024
f228aae
coverage
dmulcahey Mar 22, 2024
161d2f5
coverage
dmulcahey Mar 22, 2024
e625eb8
device tracker tests
dmulcahey Mar 22, 2024
545a3a0
more fan coverage
dmulcahey Mar 22, 2024
1c2c85e
light coverage
dmulcahey Mar 22, 2024
0de4f59
coverage
dmulcahey Mar 23, 2024
6700064
coverage
dmulcahey Mar 23, 2024
f8ff390
coverage
dmulcahey Mar 23, 2024
51848e7
coverage
dmulcahey Mar 23, 2024
64fcd84
event relays
dmulcahey Mar 23, 2024
5814fe3
set gateway ref in config
dmulcahey Mar 24, 2024
16f0fe5
add global listeners
dmulcahey Mar 24, 2024
3f3be1f
put baud rates back
dmulcahey Mar 24, 2024
d40329d
rejigger
dmulcahey Mar 24, 2024
b0bea43
native_value
dmulcahey Mar 24, 2024
bb249e2
unify interface
dmulcahey Mar 24, 2024
e86155e
add _attr_native_unit_of_measurement
dmulcahey Mar 24, 2024
45d5942
tweak
dmulcahey Mar 24, 2024
e1fbf0c
unify interface
dmulcahey Mar 24, 2024
6ab260c
convert some events to dataclasses
dmulcahey Mar 24, 2024
394ae09
fix name
dmulcahey Mar 24, 2024
65dde4a
debug
dmulcahey Mar 24, 2024
a8628d5
name handling needs cleanup
dmulcahey Mar 24, 2024
a725909
debug
dmulcahey Mar 24, 2024
bdf032d
add color modes
dmulcahey Mar 24, 2024
4945256
rename to emit prefix
dmulcahey Mar 24, 2024
4aa3560
emit zha event
dmulcahey Mar 24, 2024
3344fc6
clean up
dmulcahey Mar 24, 2024
8122fc1
rename
dmulcahey Mar 24, 2024
c2e61ac
emit
dmulcahey Mar 24, 2024
0554bca
emit
dmulcahey Mar 24, 2024
876778d
remove ZHA prefix from class names
dmulcahey Mar 24, 2024
144ef18
remove ZHA prefix
dmulcahey Mar 24, 2024
fa76afb
remove ZHA prefix
dmulcahey Mar 24, 2024
8a23ebc
no eventing for light group stuff
dmulcahey Mar 25, 2024
c85cfb9
direct device availability
dmulcahey Mar 25, 2024
258bac6
compat layer
dmulcahey Mar 25, 2024
a7efc9a
some guards
dmulcahey Mar 25, 2024
a3ebe4b
add context
dmulcahey Mar 25, 2024
535f876
cleanup
dmulcahey Mar 26, 2024
187abcb
lock async_update cleanup
dmulcahey Mar 26, 2024
5c5b6bf
clean up switch async_update
dmulcahey Mar 26, 2024
b984e08
clean up
dmulcahey Mar 26, 2024
3166b86
clean up handle_cluster_handler_attribute_updated
dmulcahey Mar 26, 2024
c9530dd
more efficient event processing
dmulcahey Mar 26, 2024
864a9c4
fix emits
dmulcahey Mar 26, 2024
345a8a3
coverage
dmulcahey Mar 26, 2024
cbb0935
cleanup
dmulcahey Mar 26, 2024
ee8dfab
clean up
dmulcahey Mar 26, 2024
c31692c
tests
dmulcahey Mar 27, 2024
5293684
more coverage
dmulcahey Mar 27, 2024
3660fb9
initial conversion of OTA
dmulcahey Mar 27, 2024
f36073b
bust the cache and reduce cov to 92%
dmulcahey Mar 27, 2024
7805bd5
try explicit
dmulcahey Mar 27, 2024
8c05c9b
oops
dmulcahey Mar 27, 2024
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
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[report]
show_missing = True
exclude_also =
if TYPE_CHECKING:
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
uses: zigpy/workflows/.github/workflows/ci.yml@main
with:
CODE_FOLDER: zha
CACHE_VERSION: 1
CACHE_VERSION: 2
PYTHON_VERSION_DEFAULT: 3.12
PRE_COMMIT_CACHE_PATH: ~/.cache/pre-commit
MINIMUM_COVERAGE_PERCENTAGE: 100
MINIMUM_COVERAGE_PERCENTAGE: 92
PYTHON_MATRIX: "3.12"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand Down
325 changes: 25 additions & 300 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ readme = "README.md"
license = {text = "GPL-3.0"}
requires-python = ">=3.12"
dependencies = [
"bellows==0.38.1",
"pyserial==3.5",
"pyserial-asyncio==0.6",
"zha-quirks==0.0.112",
"zigpy-deconz==0.23.1",
"zigpy>=0.63.5",
"zigpy-xbee==0.20.1",
"zigpy-zigate==0.12.0",
"zigpy-znp==0.12.1",
"universal-silabs-flasher==0.0.18",
"pyserial-asyncio-fast==0.11",
"python-slugify==8.0.4",
"awesomeversion==24.2.0",
]

[tool.setuptools.packages.find]
Expand All @@ -28,6 +40,9 @@ testing = [
[tool.setuptools-git-versioning]
enabled = true

[tool.codespell]
ignore-words-list = "hass"

[tool.mypy]
python_version = "3.12"
check_untyped_defs = true
Expand Down Expand Up @@ -68,307 +83,17 @@ disable_error_code = [
"var-annotated",
]

[tool.pylint.BASIC]
class-const-naming-style = "any"

[tool.pylint."MESSAGES CONTROL"]
# Reasons disabled:
# format - handled by ruff
# locally-disabled - it spams too much
# duplicate-code - unavoidable
# cyclic-import - doesn't test if both import on load
# abstract-class-little-used - prevents from setting right foundation
# unused-argument - generic callbacks and setup methods create a lot of warnings
# too-many-* - are not enforced for the sake of readability
# too-few-* - same as too-many-*
# abstract-method - with intro of async there are always methods missing
# inconsistent-return-statements - doesn't handle raise
# too-many-ancestors - it's too strict.
# wrong-import-order - isort guards this
# consider-using-f-string - str.format sometimes more readable
# ---
# Pylint CodeStyle plugin
# consider-using-namedtuple-or-dataclass - too opinionated
# consider-using-assignment-expr - decision to use := better left to devs
disable = [
"format",
"abstract-method",
"cyclic-import",
"duplicate-code",
"inconsistent-return-statements",
"locally-disabled",
"not-context-manager",
"too-few-public-methods",
"too-many-ancestors",
"too-many-arguments",
"too-many-instance-attributes",
"too-many-lines",
"too-many-locals",
"too-many-public-methods",
"too-many-boolean-expressions",
"wrong-import-order",
"consider-using-f-string",
"consider-using-namedtuple-or-dataclass",
"consider-using-assignment-expr",

# Handled by ruff
# Ref: <https://github.com/astral-sh/ruff/issues/970>
"await-outside-async", # PLE1142
"bad-str-strip-call", # PLE1310
"bad-string-format-type", # PLE1307
"bidirectional-unicode", # PLE2502
"continue-in-finally", # PLE0116
"duplicate-bases", # PLE0241
"format-needs-mapping", # F502
"function-redefined", # F811
# Needed because ruff does not understand type of __all__ generated by a function
# "invalid-all-format", # PLE0605
"invalid-all-object", # PLE0604
"invalid-character-backspace", # PLE2510
"invalid-character-esc", # PLE2513
"invalid-character-nul", # PLE2514
"invalid-character-sub", # PLE2512
"invalid-character-zero-width-space", # PLE2515
"logging-too-few-args", # PLE1206
"logging-too-many-args", # PLE1205
"missing-format-string-key", # F524
"mixed-format-string", # F506
"no-method-argument", # N805
"no-self-argument", # N805
"nonexistent-operator", # B002
"nonlocal-without-binding", # PLE0117
"not-in-loop", # F701, F702
"notimplemented-raised", # F901
"return-in-init", # PLE0101
"return-outside-function", # F706
"syntax-error", # E999
"too-few-format-args", # F524
"too-many-format-args", # F522
"too-many-star-expressions", # F622
"truncated-format-string", # F501
"undefined-all-variable", # F822
"undefined-variable", # F821
"used-prior-global-declaration", # PLE0118
"yield-inside-async-function", # PLE1700
"yield-outside-function", # F704
"anomalous-backslash-in-string", # W605
"assert-on-string-literal", # PLW0129
"assert-on-tuple", # F631
"bad-format-string", # W1302, F
"bad-format-string-key", # W1300, F
"bare-except", # E722
"binary-op-exception", # PLW0711
"cell-var-from-loop", # B023
# "dangerous-default-value", # B006, ruff catches new occurrences, needs more work
"duplicate-except", # B014
"duplicate-key", # F601
"duplicate-string-formatting-argument", # F
"duplicate-value", # F
"eval-used", # S307
"exec-used", # S102
# "expression-not-assigned", # B018, ruff catches new occurrences, needs more work
"f-string-without-interpolation", # F541
"forgotten-debug-statement", # T100
"format-string-without-interpolation", # F
# "global-statement", # PLW0603, ruff catches new occurrences, needs more work
"global-variable-not-assigned", # PLW0602
"implicit-str-concat", # ISC001
"import-self", # PLW0406
"inconsistent-quotes", # Q000
"invalid-envvar-default", # PLW1508
"keyword-arg-before-vararg", # B026
"logging-format-interpolation", # G
"logging-fstring-interpolation", # G
"logging-not-lazy", # G
"misplaced-future", # F404
"named-expr-without-context", # PLW0131
"nested-min-max", # PLW3301
# "pointless-statement", # B018, ruff catches new occurrences, needs more work
"raise-missing-from", # B904
# "redefined-builtin", # A001, ruff is way more stricter, needs work
"try-except-raise", # TRY302
"unused-argument", # ARG001, we don't use it
"unused-format-string-argument", #F507
"unused-format-string-key", # F504
"unused-import", # F401
"unused-variable", # F841
"useless-else-on-loop", # PLW0120
"wildcard-import", # F403
"bad-classmethod-argument", # N804
"consider-iterating-dictionary", # SIM118
"empty-docstring", # D419
"invalid-name", # N815
"line-too-long", # E501, disabled globally
"missing-class-docstring", # D101
"missing-final-newline", # W292
"missing-function-docstring", # D103
"missing-module-docstring", # D100
"multiple-imports", #E401
"singleton-comparison", # E711, E712
"subprocess-run-check", # PLW1510
"superfluous-parens", # UP034
"ungrouped-imports", # I001
"unidiomatic-typecheck", # E721
"unnecessary-direct-lambda-call", # PLC3002
"unnecessary-lambda-assignment", # PLC3001
"unneeded-not", # SIM208
"useless-import-alias", # PLC0414
"wrong-import-order", # I001
"wrong-import-position", # E402
"comparison-of-constants", # PLR0133
"comparison-with-itself", # PLR0124
"consider-alternative-union-syntax", # UP007
"consider-merging-isinstance", # PLR1701
"consider-using-alias", # UP006
"consider-using-dict-comprehension", # C402
"consider-using-generator", # C417
"consider-using-get", # SIM401
"consider-using-set-comprehension", # C401
"consider-using-sys-exit", # PLR1722
"consider-using-ternary", # SIM108
"literal-comparison", # F632
"property-with-parameters", # PLR0206
"super-with-arguments", # UP008
"too-many-branches", # PLR0912
"too-many-return-statements", # PLR0911
"too-many-statements", # PLR0915
"trailing-comma-tuple", # COM818
"unnecessary-comprehension", # C416
"use-a-generator", # C417
"use-dict-literal", # C406
"use-list-literal", # C405
"useless-object-inheritance", # UP004
"useless-return", # PLR1711
# "no-self-use", # PLR6301 # Optional plugin, not enabled

# Handled by mypy
# Ref: <https://github.com/antonagestam/pylint-mypy-overlap>
"abstract-class-instantiated",
"arguments-differ",
"assigning-non-slot",
"assignment-from-no-return",
"assignment-from-none",
"bad-exception-cause",
"bad-format-character",
"bad-reversed-sequence",
"bad-super-call",
"bad-thread-instantiation",
"catching-non-exception",
"comparison-with-callable",
"deprecated-class",
"dict-iter-missing-items",
"format-combined-specification",
"global-variable-undefined",
"import-error",
"inconsistent-mro",
"inherit-non-class",
"init-is-generator",
"invalid-class-object",
"invalid-enum-extension",
"invalid-envvar-value",
"invalid-format-returned",
"invalid-hash-returned",
"invalid-metaclass",
"invalid-overridden-method",
"invalid-repr-returned",
"invalid-sequence-index",
"invalid-slice-index",
"invalid-slots-object",
"invalid-slots",
"invalid-star-assignment-target",
"invalid-str-returned",
"invalid-unary-operand-type",
"invalid-unicode-codec",
"isinstance-second-argument-not-valid-type",
"method-hidden",
"misplaced-format-function",
"missing-format-argument-key",
"missing-format-attribute",
"missing-kwoa",
"no-member",
"no-value-for-parameter",
"non-iterator-returned",
"non-str-assignment-to-dunder-name",
"nonlocal-and-global",
"not-a-mapping",
"not-an-iterable",
"not-async-context-manager",
"not-callable",
"not-context-manager",
"overridden-final-method",
"raising-bad-type",
"raising-non-exception",
"redundant-keyword-arg",
"relative-beyond-top-level",
"self-cls-assignment",
"signature-differs",
"star-needs-assignment-target",
"subclassed-final-class",
"super-without-brackets",
"too-many-function-args",
"typevar-double-variance",
"typevar-name-mismatch",
"unbalanced-dict-unpacking",
"unbalanced-tuple-unpacking",
"unexpected-keyword-arg",
"unhashable-member",
"unpacking-non-sequence",
"unsubscriptable-object",
"unsupported-assignment-operation",
"unsupported-binary-operation",
"unsupported-delete-operation",
"unsupported-membership-test",
"used-before-assignment",
"using-final-decorator-in-unsupported-version",
"wrong-exception-operation",
]
enable = [
#"useless-suppression", # temporarily every now and then to clean them up
"use-symbolic-message-instead",
]
per-file-ignores = [
# hass-component-root-import: Tests test non-public APIs
# protected-access: Tests do often test internals a lot
# redefined-outer-name: Tests reference fixtures in the test function
"/tests/:hass-component-root-import,protected-access,redefined-outer-name",
]

[tool.pylint.REPORTS]
score = false

[tool.pylint.TYPECHECK]
ignored-classes = [
"_CountingAttr", # for attrs
]
mixin-class-rgx = ".*[Mm]ix[Ii]n"

[tool.pylint.FORMAT]
expected-line-ending-format = "LF"
[tool.pylint]
max-line-length = 120

[tool.pylint.EXCEPTIONS]
overgeneral-exceptions = [
"builtins.BaseException",
"builtins.Exception",
]

[tool.pylint.TYPING]
runtime-typing = false

[tool.pylint.CODE_STYLE]
max-line-length-suggestions = 72
disable = ["C0103", "W0212"]

[tool.pytest.ini_options]
testpaths = [
"tests",
]
norecursedirs = [
".git",
"testing_config",
]
log_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(threadName)s %(name)s:%(filename)s:%(lineno)s %(message)s"
log_date_format = "%Y-%m-%d %H:%M:%S"
asyncio_mode = "auto"
testpaths = "tests"
norecursedirs = ".git"

[tool.ruff]
target-version = "py312"

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -488,9 +213,9 @@ ignore = [
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"async_timeout".msg = "use asyncio.timeout instead"
"pytz".msg = "use zoneinfo instead"
[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"

[tool.ruff.lint.isort]
force-sort-within-sections = true
Expand Down
2 changes: 2 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ pytest-cov
pytest-sugar
pytest-timeout
pytest-asyncio
pytest-xdist
pytest
zigpy>=0.63.5
ruff
looptime
Loading
Loading