Skip to content

Commit

Permalink
chore: Drop Python 3.10
Browse files Browse the repository at this point in the history
Debian stable has 3.11 right know.
Debian oldstable has 3.9.

Drop 3.10.
  • Loading branch information
rumpelsepp committed Dec 7, 2023
1 parent 63b2f7f commit 66fe466
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 194 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
python-version: ['3.10']
python-version: ['3.11', '3.12']

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11']
python-version: ['3.11', '3.12']

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11']
python-version: ['3.11', '3.12']

runs-on: ubuntu-latest

Expand All @@ -47,7 +47,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10']
python-version: ['3.11', '3.12']

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPDX-License-Identifier: CC0-1.0
This project has the following system level dependencies:

* [Linux](https://kernel.org) >= 5.10
* [Python](https://python.org) >= 3.10
* [Python](https://python.org) >= 3.11
* [poetry](https://python-poetry.org) >= 1.2 (optional, for development)
* [dumpcap](https://www.wireshark.org/docs/man-pages/dumpcap.html) (optional, part of [wireshark](https://www.wireshark.org/))

Expand Down
308 changes: 146 additions & 162 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.10,<3.12"
python = ">=3.11,<3.13"
aiohttp = "^3.8"
aiofiles = ">=22.1,<24.0"
aiosqlite = ">=0.18"
Expand All @@ -42,7 +42,6 @@ zstandard = ">=0.19"
python-can = "^4.2"
tabulate = ">=0.9"
construct = "^2.10"
tomli = { version = "^2.0", python = "<3.11" }
msgspec = ">=0.11,<0.19"
pydantic = "^2.0"
pygit2 = "^1.10"
Expand Down
7 changes: 2 additions & 5 deletions src/cursed_hr/cursed_hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from enum import IntEnum, unique
from math import ceil
from pathlib import Path
from typing import Any, BinaryIO, cast
from typing import Any, BinaryIO

import zstandard as zstd
from gallia.log import PenlogPriority, PenlogRecord
Expand Down Expand Up @@ -128,10 +128,7 @@ def _load_entry(self, entry_number: int) -> None:
self.entries[entry_number] = self.old_entries.pop(entry_number)
except KeyError:
try:
# TODO: Python 3.11: the cast can be dropped due to typing.Self.
self.entries[entry_number] = cast(
PenlogEntry, PenlogEntry.parse_json(line)
)
self.entries[entry_number] = PenlogEntry.parse_json(line)
except (json.decoder.JSONDecodeError, TypeError):
self.entries[entry_number] = PenlogEntry(
data=line.decode("utf-8"),
Expand Down
8 changes: 1 addition & 7 deletions src/gallia/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@
# SPDX-License-Identifier: Apache-2.0

import os
import sys
from pathlib import Path
from typing import Any

import tomllib
from platformdirs import user_config_path
from pygit2 import discover_repository

# TODO: Remove this check when dropping Python 3.10.
if sys.version_info[1] < 11:
import tomli as tomllib
else:
import tomllib


class Config(dict[str, Any]):
def get_value(self, key: str, default: Any | None = None) -> Any | None:
Expand Down
4 changes: 2 additions & 2 deletions src/gallia/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pathlib import Path
from queue import Queue
from types import TracebackType
from typing import TYPE_CHECKING, Any, BinaryIO, TextIO, TypeAlias, cast
from typing import TYPE_CHECKING, Any, BinaryIO, Self, TextIO, TypeAlias, cast

import msgspec
import zstandard
Expand Down Expand Up @@ -460,7 +460,7 @@ def parse_priority(cls, data: bytes) -> int | None:
return int(prio_str)

@classmethod
def parse_json(cls, data: bytes) -> PenlogRecord:
def parse_json(cls, data: bytes) -> Self:
if data.startswith(b"<"):
data = data[data.index(b">") + 1 :]

Expand Down
12 changes: 4 additions & 8 deletions src/gallia/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import binascii
import io
from abc import ABC, abstractmethod
from typing import Any, TypeVar
from typing import Any, Self
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse

from typing_extensions import Protocol
Expand Down Expand Up @@ -109,10 +109,6 @@ def get_reader(self) -> asyncio.StreamReader:
raise NotImplementedError


# TODO: Replace this with Self type: Python 3.11
TransportT = TypeVar("TransportT", bound="BaseTransport")


class BaseTransport(ABC):
"""BaseTransport is the base class providing the required
interface for all transports used by gallia.
Expand Down Expand Up @@ -161,10 +157,10 @@ def check_scheme(cls, target: TargetURI) -> None:
@classmethod
@abstractmethod
async def connect(
cls: type[TransportT],
cls,
target: str | TargetURI,
timeout: float | None = None,
) -> TransportT:
) -> Self:
"""Classmethod to connect the transport to a relevant target.
The target argument is a URI, such as `doip://192.0.2.2:13400?src_addr=0xf4&dst_addr=0x1d"`
An instance of the relevant transport class is returned.
Expand All @@ -174,7 +170,7 @@ async def connect(
async def close(self) -> None:
"""Terminates the connection and clean up all allocated ressources."""

async def reconnect(self: TransportT, timeout: float | None = None) -> TransportT:
async def reconnect(self, timeout: float | None = None) -> Self:
"""Closes the connection to the target and reconnects. A new
instance of this class is returned rendering the old one
obsolete. This method is safe for concurrent use.
Expand Down

0 comments on commit 66fe466

Please sign in to comment.