Skip to content

Commit

Permalink
Fix typing deprecation (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Jul 8, 2024
1 parent 1adb13c commit 176099d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@
from argparse import ArgumentParser
from pathlib import Path
from subprocess import CalledProcessError, check_output
from typing import List, Optional


def report_output(stdout: bytes, label: str) -> List[str]:
def report_output(stdout: bytes, label: str) -> list[str]:
ret = stdout.decode().strip().split("\n")
print(f"{label}: {ret}")
return ret


def get_branch_contents(ref: str) -> List[str]:
def get_branch_contents(ref: str) -> list[str]:
"""Get the list of directories in a branch."""
stdout = check_output(["git", "ls-tree", "-d", "--name-only", ref])
return report_output(stdout, "Branch contents")


def get_sorted_tags_list() -> List[str]:
def get_sorted_tags_list() -> list[str]:
"""Get a list of sorted tags in descending order from the repository."""
stdout = check_output(["git", "tag", "-l", "--sort=-v:refname"])
return report_output(stdout, "Tags list")


def get_versions(ref: str, add: Optional[str]) -> List[str]:
def get_versions(ref: str, add: str | None) -> list[str]:
"""Generate the file containing the list of all GitHub Pages builds."""
# Get the directories (i.e. builds) from the GitHub Pages branch
try:
Expand All @@ -41,7 +40,7 @@ def get_versions(ref: str, add: Optional[str]) -> List[str]:
tags = get_sorted_tags_list()

# Make the sorted versions list from main branches and tags
versions: List[str] = []
versions: list[str] = []
for version in ["master", "main"] + tags:
if version in builds:
versions.append(version)
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ repos:
language: system
entry: ruff check --force-exclude
types: [python]
exclude: ^.github/pages
require_serial: true

- id: ruff-format
name: format with ruff
language: system
entry: ruff format --force-exclude
exclude: ^.github/pages
types: [python]
require_serial: true

Expand Down
4 changes: 2 additions & 2 deletions src/daq_config_server/beamline_parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from logging import Logger
from typing import Any, Tuple, cast
from typing import Any, cast

LOGGER = Logger(__name__)
BEAMLINE_PARAMETER_KEYWORDS = ["FB", "FULL", "deadtime"]
Expand Down Expand Up @@ -30,7 +30,7 @@ def from_lines(cls, file_name: str, config_lines: list[str]):
for line in config_lines_nocomments
]
config_pairs: list[tuple[str, Any]] = [
cast(Tuple[str, Any], param)
cast(tuple[str, Any], param)
for param in config_lines_sep_key_and_value
if len(param) == 2
]
Expand Down

0 comments on commit 176099d

Please sign in to comment.