core: migrate code to benefit from 3.9 stuff (#401)

for now keeping ruff on 3.8 target version, need to sort out modules as well
This commit is contained in:
karlicoss 2024-10-19 20:55:09 +01:00 committed by GitHub
parent bc7c3ac253
commit d3f9a8e8b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 515 additions and 404 deletions

View file

@ -2,11 +2,11 @@
Helper 'module' for test_guess_stats
"""
from collections.abc import Iterable, Iterator, Sequence
from contextlib import contextmanager
from dataclasses import dataclass
from datetime import datetime, timedelta
from pathlib import Path
from typing import Iterable, Iterator, Sequence
@dataclass

View file

@ -1,6 +1,8 @@
from __future__ import annotations
import os
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Iterator, Optional
import pytest
@ -15,7 +17,7 @@ skip_if_uses_optional_deps = pytest.mark.skipif(
# TODO maybe move to hpi core?
@contextmanager
def tmp_environ_set(key: str, value: Optional[str]) -> Iterator[None]:
def tmp_environ_set(key: str, value: str | None) -> Iterator[None]:
prev_value = os.environ.get(key)
if value is None:
os.environ.pop(key, None)

View file

@ -1,8 +1,9 @@
import json
import warnings
from collections.abc import Iterator
from datetime import datetime
from pathlib import Path
from typing import Iterator, NamedTuple
from typing import NamedTuple
from ..denylist import DenyList

View file

@ -1,6 +1,6 @@
from .common import skip_if_uses_optional_deps as pytestmark
from __future__ import annotations
from typing import List
from .common import skip_if_uses_optional_deps as pytestmark
# TODO ugh, this is very messy.. need to sort out config overriding here
@ -16,7 +16,7 @@ def test_cachew() -> None:
# TODO ugh. need doublewrap or something to avoid having to pass parens
@mcachew()
def cf() -> List[int]:
def cf() -> list[int]:
nonlocal called
called += 1
return [1, 2, 3]
@ -43,7 +43,7 @@ def test_cachew_dir_none() -> None:
called = 0
@mcachew(cache_path=cache_dir() / 'ctest')
def cf() -> List[int]:
def cf() -> list[int]:
nonlocal called
called += 1
return [called, called, called]

View file

@ -2,8 +2,8 @@
Various tests that are checking behaviour of user config wrt to various things
"""
import sys
import os
import sys
from pathlib import Path
import pytest