Skip to content

Commit d74e043

Browse files
authored
Merge pull request #704 from opsmill/develop
Merge develop into infrahub-develop
2 parents 31a7720 + d215e94 commit d74e043

File tree

5 files changed

+106
-2
lines changed

5 files changed

+106
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ jobs:
9191
run: "uv run ruff check ."
9292
- name: "Linting: ruff format"
9393
run: "uv run ruff format --check --diff ."
94+
- name: "Linting: ty check"
95+
run: "uv run ty check ."
9496

9597

9698
markdown-lint:

infrahub_sdk/analyzer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class GraphQLOperation(BaseModel):
3030

3131

3232
class GraphQLQueryAnalyzer:
33-
def __init__(self, query: str, schema: GraphQLSchema | None = None) -> None:
33+
def __init__(self, query: str, schema: GraphQLSchema | None = None, document: DocumentNode | None = None) -> None:
3434
self.query: str = query
3535
self.schema: GraphQLSchema | None = schema
36-
self.document: DocumentNode = parse(self.query)
36+
self.document: DocumentNode = document or parse(self.query)
3737
self._fields: dict | None = None
3838

3939
@property

pyproject.toml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ lint = [
8282
"mypy==1.11.2",
8383
"ruff==0.14.5",
8484
"astroid>=3.1,<4.0",
85+
"ty==0.0.4",
8586
]
8687
types = [
8788
"types-ujson",
@@ -116,6 +117,68 @@ filterwarnings = [
116117
]
117118
addopts = "-vs --cov-report term-missing --cov-report xml --dist loadscope"
118119

120+
[tool.ty]
121+
122+
[tool.ty.environment]
123+
python-version = "3.10"
124+
125+
[[tool.ty.overrides]]
126+
include = ["infrahub_sdk/**"]
127+
128+
[tool.ty.overrides.rules]
129+
##################################################################################################
130+
# The ignored rules below should be removed once the code has been updated, they are included #
131+
# like this so that we can reactivate them one by one. #
132+
##################################################################################################
133+
division-by-zero = "ignore"
134+
invalid-argument-type = "ignore"
135+
invalid-assignment = "ignore"
136+
invalid-await = "ignore"
137+
invalid-return-type = "ignore"
138+
invalid-type-form = "ignore"
139+
missing-argument = "ignore"
140+
no-matching-overload = "ignore"
141+
possibly-unresolved-reference = "ignore"
142+
redundant-cast = "ignore"
143+
too-many-positional-arguments = "ignore"
144+
type-assertion-failure = "ignore"
145+
unknown-argument = "ignore"
146+
unresolved-attribute = "ignore"
147+
unresolved-import = "ignore"
148+
unsupported-operator = "ignore"
149+
150+
151+
[[tool.ty.overrides]]
152+
include = ["tests/**"]
153+
154+
[tool.ty.overrides.rules]
155+
##################################################################################################
156+
# The ignored rules below should be removed once the code has been updated, they are included #
157+
# like this so that we can reactivate them one by one. #
158+
##################################################################################################
159+
invalid-argument-type = "ignore"
160+
invalid-assignment = "ignore"
161+
invalid-method-override = "ignore"
162+
invalid-return-type = "ignore"
163+
no-matching-overload = "ignore"
164+
non-subscriptable = "ignore"
165+
not-iterable = "ignore"
166+
possibly-missing-attribute = "ignore"
167+
unresolved-attribute = "ignore"
168+
unresolved-import = "ignore"
169+
170+
171+
[[tool.ty.overrides]]
172+
include = ["docs/**"]
173+
174+
[tool.ty.overrides.rules]
175+
##################################################################################################
176+
# The ignored rules below should be removed once the code has been updated, they are included #
177+
# like this so that we can reactivate them one by one. #
178+
##################################################################################################
179+
invalid-assignment = "ignore"
180+
181+
119182
[tool.mypy]
120183
pretty = true
121184
ignore_missing_imports = true

tasks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ def lint_mypy(context: Context) -> None:
173173
context.run(exec_cmd)
174174

175175

176+
@task
177+
def lint_ty(context: Context) -> None:
178+
"""Run ty type checker against all Python files."""
179+
print(" - Check code with ty")
180+
exec_cmd = "uv run ty check ."
181+
with context.cd(MAIN_DIRECTORY_PATH):
182+
context.run(exec_cmd)
183+
184+
176185
@task
177186
def lint_ruff(context: Context) -> None:
178187
"""Run Linter to check all Python files."""
@@ -220,6 +229,7 @@ def lint_all(context: Context) -> None:
220229
"""Run all linters."""
221230
lint_yaml(context)
222231
lint_ruff(context)
232+
lint_ty(context)
223233
lint_mypy(context)
224234
lint_docs(context)
225235

uv.lock

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)