Skip to content

Commit b61ea64

Browse files
committed
Fix typing for Python 3.9 and remove support for Python 3.13
1 parent d9ed642 commit b61ea64

File tree

14 files changed

+35
-57
lines changed

14 files changed

+35
-57
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ jobs:
126126
- "3.10"
127127
- "3.11"
128128
- "3.12"
129-
- "3.13"
130129
if: |
131130
always() && !cancelled() &&
132131
!contains(needs.*.result, 'failure') &&
@@ -144,7 +143,7 @@ jobs:
144143
python-version: ${{ matrix.python-version }}
145144
- name: "Setup environment"
146145
run: |
147-
pipx install poetry==1.8.5
146+
pipx install poetry==1.8.5 --python python${{ matrix.python-version }}
148147
poetry config virtualenvs.create true --local
149148
pip install invoke toml codecov
150149
- name: "Install Package"

changelog/251.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix typing for Python 3.9 and remove support for Python 3.13

infrahub_sdk/ctl/check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from asyncio import run as aiorun
66
from dataclasses import dataclass
77
from pathlib import Path
8-
from typing import TYPE_CHECKING
8+
from typing import TYPE_CHECKING, Optional
99

1010
import typer
1111
from rich.console import Console
@@ -50,8 +50,8 @@ def run(
5050
format_json: bool,
5151
list_available: bool,
5252
variables: dict[str, str],
53-
name: str | None = None,
54-
branch: str | None = None,
53+
name: Optional[str] = None,
54+
branch: Optional[str] = None,
5555
) -> None:
5656
"""Locate and execute all checks under the defined path."""
5757

infrahub_sdk/ctl/cli_commands.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import platform
88
import sys
99
from pathlib import Path
10-
from typing import TYPE_CHECKING, Any, Callable
10+
from typing import TYPE_CHECKING, Any, Callable, Optional
1111

1212
import jinja2
1313
import typer
@@ -74,13 +74,13 @@
7474
@catch_exception(console=console)
7575
def check(
7676
check_name: str = typer.Argument(default="", help="Name of the Python check"),
77-
branch: str | None = None,
77+
branch: Optional[str] = None,
7878
path: str = typer.Option(".", help="Root directory"),
7979
debug: bool = False,
8080
format_json: bool = False,
8181
_: str = CONFIG_PARAM,
8282
list_available: bool = typer.Option(False, "--list", help="Show available Python checks"),
83-
variables: list[str] | None = typer.Argument(
83+
variables: Optional[list[str]] = typer.Argument(
8484
None, help="Variables to pass along with the query. Format key=value key=value."
8585
),
8686
) -> None:
@@ -102,12 +102,12 @@ def check(
102102
@catch_exception(console=console)
103103
async def generator(
104104
generator_name: str = typer.Argument(default="", help="Name of the Generator"),
105-
branch: str | None = None,
105+
branch: Optional[str] = None,
106106
path: str = typer.Option(".", help="Root directory"),
107107
debug: bool = False,
108108
_: str = CONFIG_PARAM,
109109
list_available: bool = typer.Option(False, "--list", help="Show available Generators"),
110-
variables: list[str] | None = typer.Argument(
110+
variables: Optional[list[str]] = typer.Argument(
111111
None, help="Variables to pass along with the query. Format key=value key=value."
112112
),
113113
) -> None:
@@ -130,13 +130,13 @@ async def run(
130130
debug: bool = False,
131131
_: str = CONFIG_PARAM,
132132
branch: str = typer.Option("main", help="Branch on which to run the script."), # TODO: Replace main by None
133-
concurrent: int | None = typer.Option(
133+
concurrent: Optional[int] = typer.Option(
134134
None,
135135
help="Maximum number of requests to execute at the same time.",
136136
envvar="INFRAHUB_MAX_CONCURRENT_EXECUTION",
137137
),
138138
timeout: int = typer.Option(60, help="Timeout in sec", envvar="INFRAHUB_TIMEOUT"),
139-
variables: list[str] | None = typer.Argument(
139+
variables: Optional[list[str]] = typer.Argument(
140140
None, help="Variables to pass along with the query. Format key=value key=value."
141141
),
142142
) -> None:
@@ -259,7 +259,7 @@ def _run_transform(
259259
@catch_exception(console=console)
260260
def render(
261261
transform_name: str = typer.Argument(default="", help="Name of the Python transformation", show_default=False),
262-
variables: list[str] | None = typer.Argument(
262+
variables: Optional[list[str]] = typer.Argument(
263263
None, help="Variables to pass along with the query. Format key=value key=value."
264264
),
265265
branch: str = typer.Option(None, help="Branch on which to render the transform."),
@@ -309,7 +309,7 @@ def render(
309309
@catch_exception(console=console)
310310
def transform(
311311
transform_name: str = typer.Argument(default="", help="Name of the Python transformation", show_default=False),
312-
variables: list[str] | None = typer.Argument(
312+
variables: Optional[list[str]] = typer.Argument(
313313
None, help="Variables to pass along with the query. Format key=value key=value."
314314
),
315315
branch: str = typer.Option(None, help="Branch on which to run the transformation"),

infrahub_sdk/ctl/generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from pathlib import Path
4-
from typing import TYPE_CHECKING
4+
from typing import TYPE_CHECKING, Optional
55

66
import typer
77
from rich.console import Console
@@ -23,7 +23,7 @@ async def run(
2323
debug: bool, # noqa: ARG001
2424
list_available: bool,
2525
branch: str | None = None,
26-
variables: list[str] | None = None,
26+
variables: Optional[list[str]] = None,
2727
) -> None:
2828
repository_config = get_repository_config(Path(config.INFRAHUB_REPO_CONFIG_FILE))
2929

infrahub_sdk/ctl/importer.py

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

33
from asyncio import run as aiorun
44
from pathlib import Path
5+
from typing import Optional
56

67
import typer
78
from rich.console import Console
@@ -26,7 +27,7 @@ def load(
2627
quiet: bool = typer.Option(False, help="No console output"),
2728
_: str = CONFIG_PARAM,
2829
branch: str = typer.Option("main", help="Branch from which to export"), # TODO: Replace main by None
29-
concurrent: int | None = typer.Option(
30+
concurrent: Optional[int] = typer.Option(
3031
None,
3132
help="Maximum number of requests to execute at the same time.",
3233
envvar="INFRAHUB_MAX_CONCURRENT_EXECUTION",

infrahub_sdk/ctl/repository.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from pathlib import Path
4+
from typing import Optional
45

56
import typer
67
import yaml
@@ -68,7 +69,7 @@ async def add(
6869
name: str,
6970
location: str,
7071
description: str = "",
71-
username: str | None = None,
72+
username: Optional[str] = None,
7273
password: str = "",
7374
ref: str = "",
7475
read_only: bool = False,
@@ -115,7 +116,7 @@ async def add(
115116

116117
@app.command()
117118
async def list(
118-
branch: str | None = None,
119+
branch: Optional[str] = None,
119120
debug: bool = False,
120121
_: str = CONFIG_PARAM,
121122
) -> None:

infrahub_sdk/ctl/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections.abc import Coroutine
77
from functools import wraps
88
from pathlib import Path
9-
from typing import TYPE_CHECKING, Any, Callable, NoReturn, TypeVar
9+
from typing import TYPE_CHECKING, Any, Callable, NoReturn, Optional, TypeVar
1010

1111
import pendulum
1212
import typer
@@ -145,7 +145,7 @@ def print_graphql_errors(console: Console, errors: list) -> None:
145145
console.print(f"[red]{escape(str(error))}")
146146

147147

148-
def parse_cli_vars(variables: list[str] | None) -> dict[str, str]:
148+
def parse_cli_vars(variables: Optional[list[str]]) -> dict[str, str]:
149149
if not variables:
150150
return {}
151151

infrahub_sdk/ctl/validate.py

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

33
import sys
44
from pathlib import Path
5+
from typing import Optional
56

67
import typer
78
import ujson
@@ -57,7 +58,7 @@ async def validate_schema(schema: Path, _: str = CONFIG_PARAM) -> None:
5758
@catch_exception(console=console)
5859
def validate_graphql(
5960
query: str,
60-
variables: list[str] | None = typer.Argument(
61+
variables: Optional[list[str]] = typer.Argument(
6162
None, help="Variables to pass along with the query. Format key=value key=value."
6263
),
6364
debug: bool = typer.Option(False, help="Display more troubleshooting information."),

poetry.lock

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

0 commit comments

Comments
 (0)