1
1
# pyproject.toml
2
2
3
- # [tool.setuptools.packages.find]
4
- # where = ["custom_components/"]
5
- # include = ["bms_ble"]
3
+ [project ]
4
+ name = " BMS_BLE-HA"
5
+ classifiers = [
6
+ " License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)" ,
7
+ " Programming Language :: Python :: 3"
8
+ ]
9
+ description = " Integration that allows monitoring of Bluetooth Low Energy (BLE) battery management systems (BMS) from within Home Assistant."
10
+ readme = " README.md"
11
+
12
+ [project .urls ]
13
+ "Source Code" = " https://github.com/patman15/BMS_BLE-HA"
14
+ "Bug Reports" = " https://github.com/patman15/BMS_BLE-HA/issues"
6
15
7
16
[tool .pytest .ini_options ]
8
17
minversion = " 8.0"
@@ -14,3 +23,167 @@ testpaths = [
14
23
" tests" ,
15
24
]
16
25
asyncio_mode = " auto"
26
+
27
+ # ruff settings from HA 2024.12.0.dev0
28
+ [tool .ruff ]
29
+ required-version = " >=0.6.8"
30
+
31
+ [tool .ruff .lint ]
32
+ select = [
33
+ " A001" , # Variable {name} is shadowing a Python builtin
34
+ " ASYNC210" , # Async functions should not call blocking HTTP methods
35
+ " ASYNC220" , # Async functions should not create subprocesses with blocking methods
36
+ " ASYNC221" , # Async functions should not run processes with blocking methods
37
+ " ASYNC222" , # Async functions should not wait on processes with blocking methods
38
+ " ASYNC230" , # Async functions should not open files with blocking methods like open
39
+ " ASYNC251" , # Async functions should not call time.sleep
40
+ " B002" , # Python does not support the unary prefix increment
41
+ " B005" , # Using .strip() with multi-character strings is misleading
42
+ " B007" , # Loop control variable {name} not used within loop body
43
+ " B014" , # Exception handler with duplicate exception
44
+ " B015" , # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it.
45
+ " B017" , # pytest.raises(BaseException) should be considered evil
46
+ " B018" , # Found useless attribute access. Either assign it to a variable or remove it.
47
+ " B023" , # Function definition does not bind loop variable {name}
48
+ " B026" , # Star-arg unpacking after a keyword argument is strongly discouraged
49
+ " B032" , # Possible unintentional type annotation (using :). Did you mean to assign (using =)?
50
+ " B904" , # Use raise from to specify exception cause
51
+ " B905" , # zip() without an explicit strict= parameter
52
+ " BLE" ,
53
+ " C" , # complexity
54
+ " COM818" , # Trailing comma on bare tuple prohibited
55
+ " D" , # docstrings
56
+ " DTZ003" , # Use datetime.now(tz=) instead of datetime.utcnow()
57
+ " DTZ004" , # Use datetime.fromtimestamp(ts, tz=) instead of datetime.utcfromtimestamp(ts)
58
+ " E" , # pycodestyle
59
+ " F" , # pyflakes/autoflake
60
+ " F541" , # f-string without any placeholders
61
+ " FLY" , # flynt
62
+ " FURB" , # refurb
63
+ " G" , # flake8-logging-format
64
+ " I" , # isort
65
+ " INP" , # flake8-no-pep420
66
+ " ISC" , # flake8-implicit-str-concat
67
+ " ICN001" , # import concentions; {name} should be imported as {asname}
68
+ " LOG" , # flake8-logging
69
+ " N804" , # First argument of a class method should be named cls
70
+ " N805" , # First argument of a method should be named self
71
+ " N815" , # Variable {name} in class scope should not be mixedCase
72
+ " PERF" , # Perflint
73
+ " PGH" , # pygrep-hooks
74
+ " PIE" , # flake8-pie
75
+ " PL" , # pylint
76
+ " PT" , # flake8-pytest-style
77
+ " PTH" , # flake8-pathlib
78
+ " PYI" , # flake8-pyi
79
+ " RET" , # flake8-return
80
+ " RSE" , # flake8-raise
81
+ " RUF005" , # Consider iterable unpacking instead of concatenation
82
+ " RUF006" , # Store a reference to the return value of asyncio.create_task
83
+ " RUF010" , # Use explicit conversion flag
84
+ " RUF013" , # PEP 484 prohibits implicit Optional
85
+ " RUF017" , # Avoid quadratic list summation
86
+ " RUF018" , # Avoid assignment expressions in assert statements
87
+ " RUF019" , # Unnecessary key check before dictionary access
88
+ # "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up
89
+ " S102" , # Use of exec detected
90
+ " S103" , # bad-file-permissions
91
+ " S108" , # hardcoded-temp-file
92
+ " S306" , # suspicious-mktemp-usage
93
+ " S307" , # suspicious-eval-usage
94
+ " S313" , # suspicious-xmlc-element-tree-usage
95
+ " S314" , # suspicious-xml-element-tree-usage
96
+ " S315" , # suspicious-xml-expat-reader-usage
97
+ " S316" , # suspicious-xml-expat-builder-usage
98
+ " S317" , # suspicious-xml-sax-usage
99
+ " S318" , # suspicious-xml-mini-dom-usage
100
+ " S319" , # suspicious-xml-pull-dom-usage
101
+ " S320" , # suspicious-xmle-tree-usage
102
+ " S601" , # paramiko-call
103
+ " S602" , # subprocess-popen-with-shell-equals-true
104
+ " S604" , # call-with-shell-equals-true
105
+ " S608" , # hardcoded-sql-expression
106
+ " S609" , # unix-command-wildcard-injection
107
+ " SIM" , # flake8-simplify
108
+ " SLF" , # flake8-self
109
+ " SLOT" , # flake8-slots
110
+ " T100" , # Trace found: {name} used
111
+ " T20" , # flake8-print
112
+ " TCH" , # flake8-type-checking
113
+ " TID" , # Tidy imports
114
+ " TRY" , # tryceratops
115
+ " UP" , # pyupgrade
116
+ " UP031" , # Use format specifiers instead of percent format
117
+ " UP032" , # Use f-string instead of `format` call
118
+ " W" , # pycodestyle
119
+ ]
120
+
121
+ ignore = [
122
+ " D202" , # No blank lines allowed after function docstring
123
+ " D203" , # 1 blank line required before class docstring
124
+ " D213" , # Multi-line docstring summary should start at the second line
125
+ " D406" , # Section name should end with a newline
126
+ " D407" , # Section name underlining
127
+ " E501" , # line too long
128
+
129
+ # "PLC1901", # {existing} can be simplified to {replacement} as an empty string is falsey; too many false positives
130
+ # "PLR0911", # Too many return statements ({returns} > {max_returns})
131
+ # "PLR0912", # Too many branches ({branches} > {max_branches})
132
+ " PLR0913" , # Too many arguments to function call ({c_args} > {max_args})
133
+ # "PLR0915", # Too many statements ({statements} > {max_statements})
134
+ " PLR2004" , # Magic value used in comparison, consider replacing {value} with a constant variable
135
+ # "PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
136
+ " PT004" , # Fixture {fixture} does not return anything, add leading underscore
137
+ # "PT011", # pytest.raises({exception}) is too broad, set the `match` parameter or use a more specific exception
138
+ " PT018" , # Assertion should be broken down into multiple parts
139
+ # "RUF001", # String contains ambiguous unicode character.
140
+ # "RUF002", # Docstring contains ambiguous unicode character.
141
+ # "RUF003", # Comment contains ambiguous unicode character.
142
+ # "RUF015", # Prefer next(...) over single element slice
143
+ " SIM102" , # Use a single if statement instead of nested if statements
144
+ # "SIM103", # Return the condition {condition} directly
145
+ # "SIM108", # Use ternary operator {contents} instead of if-else-block
146
+ # "SIM115", # Use context handler for opening files
147
+
148
+ # Moving imports into type-checking blocks can mess with pytest.patch()
149
+ " TCH001" , # Move application import {} into a type-checking block
150
+ " TCH002" , # Move third-party import {} into a type-checking block
151
+ " TCH003" , # Move standard library import {} into a type-checking block
152
+
153
+ " TRY003" , # Avoid specifying long messages outside the exception class
154
+ " TRY400" , # Use `logging.exception` instead of `logging.error`
155
+ # Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923
156
+ " UP038" , # Use `X | Y` in `isinstance` call instead of `(X, Y)`
157
+
158
+ # May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
159
+ " W191" ,
160
+ " E111" ,
161
+ " E114" ,
162
+ " E117" ,
163
+ " D206" ,
164
+ " D300" ,
165
+ " Q" ,
166
+ " COM812" ,
167
+ " COM819" ,
168
+ " ISC001" ,
169
+
170
+ # Disabled because ruff does not understand type of __all__ generated by a function
171
+ " PLE0605"
172
+ ]
173
+
174
+
175
+ [tool .ruff .lint .isort ]
176
+ force-sort-within-sections = true
177
+ known-first-party = [
178
+ " homeassistant" ,
179
+ ]
180
+ combine-as-imports = true
181
+ split-on-trailing-comma = false
182
+
183
+ [tool .ruff .lint .per-file-ignores ]
184
+
185
+ # Temporary for BMS_BLE-HA
186
+ "tests/**" = [" SLF" ]
187
+
188
+ [tool .ruff .lint .mccabe ]
189
+ max-complexity = 25
0 commit comments