Skip to content

Commit

Permalink
Upgrade Ruff target version to Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianonicolai committed Nov 28, 2023
1 parent 1a80ada commit 37e9b9d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ builtins = ["__"]
fix = true
line-length = 100
select = ["ALL"]
target-version = "py39"
target-version = "py311"

[tool.ruff.flake8-pytest-style]
parametrize-values-type = "tuple"
Expand Down
6 changes: 3 additions & 3 deletions src/ansible_development_environment/subcommands/treemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Union
from typing import TYPE_CHECKING

from ansible_development_environment.tree import Tree
from ansible_development_environment.utils import builder_introspect, collect_manifests
Expand All @@ -13,8 +13,8 @@
from ansible_development_environment.config import Config
from ansible_development_environment.output import Output

ScalarVal = Union[bool, str, float, int, None]
JSONVal = Union[ScalarVal, list["JSONVal"], dict[str, "JSONVal"]]
ScalarVal = bool | str | float | int | None
JSONVal = ScalarVal | list["JSONVal"] | dict[str, "JSONVal"]


class TreeMaker:
Expand Down
10 changes: 4 additions & 6 deletions src/ansible_development_environment/tree.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""An ascii tree generator."""
from __future__ import annotations

from typing import Union

from .utils import Ansi, TermFeatures, term_link


ScalarVal = Union[bool, str, float, int, None]
JSONVal = Union[ScalarVal, list["JSONVal"], dict[str, "JSONVal"]]
ScalarVal = bool | str | float | int | None
JSONVal = ScalarVal | list["JSONVal"] | dict[str, "JSONVal"]


class Tree: # pylint: disable=R0902
Expand Down Expand Up @@ -87,7 +85,7 @@ def in_color(self: Tree, val: ScalarVal) -> str:
@staticmethod
def is_scalar(obj: JSONVal) -> bool:
"""Check if the object is a scalar."""
return isinstance(obj, (str, int, float, bool)) or obj is None
return isinstance(obj, str | int | float | bool) or obj is None

def _print_tree( # noqa: C901, PLR0913, PLR0912
self: Tree,
Expand Down Expand Up @@ -137,7 +135,7 @@ def _print_tree( # noqa: C901, PLR0913, PLR0912
)

elif isinstance(obj, list):
is_complex = any(isinstance(item, (dict, list)) for item in obj)
is_complex = any(isinstance(item, dict | list) for item in obj)
is_long = len(obj) > 1
if is_complex and is_long:
repr_obj = {str(i): item for i, item in enumerate(obj)}
Expand Down
6 changes: 3 additions & 3 deletions src/ansible_development_environment/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import time

from dataclasses import dataclass
from typing import TYPE_CHECKING, Union
from typing import TYPE_CHECKING

import subprocess_tee
import yaml
Expand All @@ -30,8 +30,8 @@
logger = logging.getLogger(__name__)


ScalarVal = Union[bool, str, float, int, None]
JSONVal = Union[ScalarVal, list["JSONVal"], dict[str, "JSONVal"]]
ScalarVal = bool | str | float | int | None
JSONVal = ScalarVal | list["JSONVal"] | dict[str, "JSONVal"]


@dataclass
Expand Down

0 comments on commit 37e9b9d

Please sign in to comment.