Skip to content

Commit 7fa25ba

Browse files
committed
Refactor code to be static-typechecked
1 parent b8e05c2 commit 7fa25ba

36 files changed

+1023
-881
lines changed

examples/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from saic_ismart_client_ng.model import SaicApiConfiguration
99

1010

11-
async def main():
11+
async def main() -> None:
1212
config = SaicApiConfiguration(
1313
username="[email protected]",
1414
password="XXXXX",

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
[tool.poetry]
1+
[project]
22
name = "saic_ismart_client_ng"
3-
homepage = "https://github.com/SAIC-iSmart-API/saic-python-client-ng"
4-
version = "0.7.1"
3+
version = "0.8.0"
54
description = "SAIC next gen client library (MG iSMART)"
65
authors = [
7-
"Giovanni Condello <[email protected]>",
6+
{ name = "Giovanni Condello", email = "[email protected]" },
87
]
98
readme = "README.md"
109

@@ -14,17 +13,18 @@ classifiers = [
1413
"Operating System :: OS Independent",
1514
]
1615

17-
[tool.poetry.urls]
18-
"Bug Tracker" = "https://github.com/SAIC-iSmart-API/saic-python-client-ng/issues"
16+
requires-python = "^3.11"
1917

18+
dependencies = [
19+
"pycryptodome (>=3.20.0,<4.0.0)",
20+
"httpx (>=0.27.0,<0.29.0)",
21+
"tenacity (>=9.0.0,<10.0.0)",
22+
"dacite (>=1.8.1,<2.0.0)"
23+
]
2024

21-
[tool.poetry.dependencies]
22-
python = "^3.11"
23-
pycryptodome = "^3.20.0"
24-
httpx = ">=0.27.0,<0.29.0"
25-
tenacity = "^9.0.0"
26-
dacite = "^1.8.1"
27-
25+
[project.urls]
26+
Homepage = "https://github.com/SAIC-iSmart-API/saic-python-client-ng"
27+
Issues = "https://github.com/SAIC-iSmart-API/saic-python-client-ng/issues"
2828

2929
[tool.poetry.group.dev.dependencies]
3030
pytest = "^8.2.2"
@@ -53,7 +53,7 @@ mock_use_standalone_module = true
5353
addopts = [
5454
"--import-mode=importlib",
5555
]
56-
asyncio_default_fixture_loop_scope="function"
56+
asyncio_default_fixture_loop_scope = "function"
5757

5858
[tool.coverage.run]
5959
omit = [
@@ -79,14 +79,20 @@ exclude_lines = [
7979
]
8080
ignore_errors = true
8181

82+
[tool.ruff]
83+
include = [
84+
"src/**/*.py",
85+
"tests/**/*.py",
86+
"**/pyproject.toml"
87+
]
8288
[tool.ruff.lint]
8389
select = ["ALL"]
8490

8591
ignore = [
8692
"ANN401", # Opinioated warning on disallowing dynamically typed expressions
87-
"D203", # Conflicts with other rules
88-
"D213", # Conflicts with other rules
89-
"EM101", # raw-string-in-exception
93+
"D203", # Conflicts with other rules
94+
"D213", # Conflicts with other rules
95+
"EM101", # raw-string-in-exception
9096

9197
"D105", # Missing docstring in magic method
9298
"D107", # Missing docstring in `__init__`
@@ -96,16 +102,27 @@ ignore = [
96102

97103
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
98104

105+
# Used to map JSON responses
106+
"N815",
99107
# Conflicts with the Ruff formatter
100108
"COM812",
101-
109+
# We use Exception istead of Error
110+
"N818",
102111
# Remove later
103-
"TD", # Todos
104-
"A", # bultins
105-
"DTZ", # use tz need to test it first
106-
"TRY", # tryceratops
112+
"D100", # Missing docstring in public module
113+
"D101", # Missing docstring in public class
114+
"D102", # Missing docstring in public method
115+
"D103", # Missing docstring in public function
116+
"D104", # Missing docstring in public package
117+
"D106", # Missing docstring in public nested class
118+
"TD", # Todos
119+
"A", # bultins
120+
"DTZ", # use tz need to test it first
121+
"TRY", # tryceratops
107122
"FIX002", # Line contains TODO, consider resolving the issue
108-
"BLE001", # Do not catch blind exception: `Exception`
123+
"BLE001", # Do not catch blind exception: `Exception`,
124+
"PLR0913", # Too many arguments in function definition
125+
"ERA001" # Commented-out code
109126

110127
]
111128

@@ -122,15 +139,15 @@ required-imports = ["from __future__ import annotations"]
122139

123140
[tool.ruff.lint.per-file-ignores]
124141
"tests/**" = [
125-
"D100", # Missing docstring in public module
126-
"D103", # Missing docstring in public function
127-
"D104", # Missing docstring in public package
128-
"N802", # Function name {name} should be lowercase
129-
"N816", # Variable {name} in global scope should not be mixedCase
142+
"D100", # Missing docstring in public module
143+
"D103", # Missing docstring in public function
144+
"D104", # Missing docstring in public package
145+
"N802", # Function name {name} should be lowercase
146+
"N816", # Variable {name} in global scope should not be mixedCase
130147
"PLR0913", # Too many arguments in function definition
131-
"S101", # Use of assert detected
132-
"SLF001", # Private member accessed: {access}
133-
"T201", # print found
148+
"S101", # Use of assert detected
149+
"SLF001", # Private member accessed: {access}
150+
"T201", # print found
134151
]
135152

136153
[tool.ruff.lint.mccabe]
@@ -193,6 +210,13 @@ disable = [
193210
"too-many-ancestors",
194211
"too-few-public-methods",
195212
"invalid-name",
213+
# Remove later
214+
"missing-function-docstring",
215+
"missing-module-docstring",
216+
"missing-class-docstring",
217+
"broad-exception-caught",
218+
"logging-fstring-interpolation",
219+
"fixme"
196220
]
197221
enable = ["useless-suppression", "use-symbolic-message-instead"]
198222

src/saic_ismart_client_ng/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from saic_ismart_client_ng.api.message import SaicMessageApi
44
from saic_ismart_client_ng.api.user import SaicUserApi
5-
from saic_ismart_client_ng.api.vehicle import SaicVehicleApi as SaicVehicleApi
65
from saic_ismart_client_ng.api.vehicle.alarm import SaicVehicleAlarmApi
76
from saic_ismart_client_ng.api.vehicle.climate import SaicVehicleClimateApi
87
from saic_ismart_client_ng.api.vehicle.locks import SaicVehicleLocksApi
@@ -19,4 +18,4 @@ class SaicApi(
1918
SaicVehicleClimateApi,
2019
SaicVehicleChargingApi,
2120
):
22-
"""The SAIC Api client"""
21+
"""The SAIC Api client."""

0 commit comments

Comments
 (0)