Skip to content
Draft
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
9 changes: 8 additions & 1 deletion .agents/rules/code-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ Do not reference specs, tasks, plans, tickets, issue numbers, user stories, or t

## Type-ignore comments

Use the standard `# type: ignore[<code>]` form (for example `# type: ignore[arg-type]`), never `# ty: ignore`. Only `# type: ignore[...]` is honored by mypy, pyright, and pytype, so a `# ty:` comment suppresses nothing and is dead.
Use the standard `# type: ignore[<code>]` form (for example `# type: ignore[arg-type]`), never `# ty: ignore`.
Inline comments carry mypy codes only.

`ty` does not read a bare mypy code as a suppression; it wants either `# ty: ignore[<code>]` or a
`ty:`-prefixed code inside the standard brackets (`# type: ignore[arg-type, ty:invalid-argument-type]`).
Do not use either form. Remaining `ty` violations belong in `[[tool.ty.overrides]]` in `pyproject.toml`,
scoped to the narrowest file or glob that covers them and annotated with the violation count so they can be
retired incrementally.
3 changes: 2 additions & 1 deletion infrahub_sdk/ctl/object/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
if TYPE_CHECKING:
from infrahub_sdk import InfrahubClient
from infrahub_sdk.node import InfrahubNode
from infrahub_sdk.node.relationship import RelationshipManager
from infrahub_sdk.schema import MainSchemaTypesAPI

console = Console()
Expand Down Expand Up @@ -205,7 +206,7 @@ def _apply_relationship(
return

# Cardinality many: access the RelationshipManager from internal storage
many_data: dict[str, object] = getattr(node, "_relationship_cardinality_many_data", {})
many_data: dict[str, RelationshipManager] = getattr(node, "_relationship_cardinality_many_data", {})
rel_manager = many_data.get(key)
if rel_manager is None or not hasattr(rel_manager, "peers"):
return
Expand Down
4 changes: 2 additions & 2 deletions infrahub_sdk/schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ async def _mutate_dropdown_attribute(
if schema_attr.kind != "Dropdown":
raise ValueError(f"Attribute '{schema_attr.name}' is not of kind Dropdown")

input_data: dict[str, Any] = {
input_data: dict[str, dict[str, Any]] = {
"data": {
"kind": node_kind,
"attribute": schema_attr.name,
Expand Down Expand Up @@ -783,7 +783,7 @@ def _mutate_dropdown_attribute(
if schema_attr.kind != "Dropdown":
raise ValueError(f"Attribute '{schema_attr.name}' is not of kind Dropdown")

input_data: dict[str, Any] = {
input_data: dict[str, dict[str, Any]] = {
"data": {
"kind": node_kind,
"attribute": schema_attr.name,
Expand Down
4 changes: 2 additions & 2 deletions infrahub_sdk/task/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _generate_query(
limit: int | None = None,
count: bool = False,
) -> Query:
query: dict[str, Any] = {
query: dict[str, dict[str, Any]] = {
"InfrahubTask": {
"edges": {
"node": {
Expand Down Expand Up @@ -92,7 +92,7 @@ def _generate_query(

@classmethod
def _generate_count_query(cls, filters: TaskFilter | None = None) -> Query:
query: dict[str, Any] = {
query: dict[str, dict[str, Any]] = {
"InfrahubTask": {
"count": None,
}
Expand Down
65 changes: 64 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ lint = [
"mypy==2.3.1",
"ruff==0.15.12",
"astroid>=3.1,<4.0",
"ty==0.0.14",
"ty==0.0.74",
"rumdl==0.2.28",
]
types = [
Expand Down Expand Up @@ -164,6 +164,40 @@ include = ["infrahub_sdk/node/node.py"]

[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 8 violations
unresolved-attribute = "ignore" # 22 violations - `_schema` is a union and only some members carry the attribute
unsupported-operator = "ignore" # 1 violation

[[tool.ty.overrides]]
include = ["infrahub_sdk/pytest_plugin/**"]

[tool.ty.overrides.rules]
unresolved-attribute = "ignore" # 35 violations - resource_config is a union of repository config element types

[[tool.ty.overrides]]
include = ["infrahub_sdk/node/attribute.py"]

[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 2 violations

[[tool.ty.overrides]]
include = ["infrahub_sdk/config.py"]

[tool.ty.overrides.rules]
invalid-return-type = "ignore" # 1 violation

[[tool.ty.overrides]]
# Mirrors the module-level mypy `return-value` override for the same code.
include = ["infrahub_sdk/utils.py"]

[tool.ty.overrides.rules]
invalid-return-type = "ignore" # 1 violation

[[tool.ty.overrides]]
# Mirrors the module-level mypy `call-overload` override for the same code.
include = ["infrahub_sdk/ctl/check.py"]

[tool.ty.overrides.rules]
no-matching-overload = "ignore" # 1 violation - `**filters` cannot be matched against `get()` overloads


[[tool.ty.overrides]]
Expand All @@ -184,6 +218,7 @@ include = ["tests/fixtures/**"]

[tool.ty.overrides.rules]
possibly-missing-attribute = "ignore" # Test fixtures use dynamic attributes
unresolved-attribute = "ignore" # 5 violations - fixtures use dynamic node attributes

# Test-specific overrides - tests have more lenient type checking
# Fix these incrementally, starting with files that have fewer violations
Expand Down Expand Up @@ -221,6 +256,7 @@ invalid-argument-type = "ignore" # ~120 violations across integration tests
invalid-assignment = "ignore"
no-matching-overload = "ignore"
possibly-missing-attribute = "ignore" # Tests use dynamic node attributes
unresolved-attribute = "ignore" # ~205 violations - `node.<field>.value` resolves to a union of attribute/relationship types

[[tool.ty.overrides]]
include = [
Expand All @@ -233,6 +269,7 @@ include = [
invalid-argument-type = "ignore" # 25 violations
invalid-assignment = "ignore"
possibly-missing-attribute = "ignore"
unresolved-attribute = "ignore" # 1 violation in test_client.py

[[tool.ty.overrides]]
include = [
Expand All @@ -245,13 +282,39 @@ include = [
"tests/unit/sdk/test_schema_sorter.py",
"tests/unit/sdk/test_topological_sort.py",
"tests/unit/sdk/test_schema_export.py",
"tests/unit/ctl/formatters/test_init.py",
"tests/unit/ctl/test_marketplace_app.py",
"tests/unit/sdk/test_file_handler.py",
"tests/unit/sdk/test_graph_traversal.py",
"tests/unit/sdk/test_store.py",
]

[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # Remaining files with 1-5 violations each
invalid-method-override = "ignore"
no-matching-overload = "ignore"

[[tool.ty.overrides]]
include = ["tests/__init__.py", "tests/unit/__init__.py", "tests/unit/sdk/pool/test_allocate.py"]

[tool.ty.overrides.rules]
unresolved-attribute = "ignore" # 5 violations - `builtins` is patched with rich helpers for tests

[[tool.ty.overrides]]
include = ["tests/conftest.py", "tests/unit/sdk/test_file_object.py"]

[tool.ty.overrides.rules]
invalid-assignment = "ignore" # 21 violations - assigning to `node.<field>.value` through a union

[[tool.ty.overrides]]
include = ["tests/unit/sdk/test_priority.py"]

[tool.ty.overrides.rules]
invalid-argument-type = "ignore" # 22 violations total
invalid-await = "ignore"
unknown-argument = "ignore"
unresolved-attribute = "ignore"

[[tool.ty.overrides]]
include = ["docs/**"]

Expand Down
45 changes: 23 additions & 22 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading