Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
fail-fast: false
matrix:
include:
- name: "pytest (3.9)"
python: "3.9"
tox: "3.9"
- name: "pytest (3.10)"
python: "3.10"
tox: "3.10"
Expand All @@ -34,6 +31,9 @@ jobs:
- name: "pytest (3.13)"
python: "3.13"
tox: "3.13"
- name: "pytest (3.14)"
python: "3.14"
tox: "3.14"
coverage: true
- name: "mypy"
python: "3.13"
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "brreg"
version = "1.3.0"
description = "API client for Brønnøysundregistrene."
authors = [{ name = "Stein Magnus Jodal", email = "stein.magnus@jodal.no" }]
requires-python = ">=3.9"
requires-python = ">=3.10"
readme = "README.md"
license = "Apache-2.0"
keywords = ["brreg", "enhetsregisteret"]
Expand Down Expand Up @@ -76,7 +76,7 @@ disallow_untyped_defs = true


[tool.pyright]
pythonVersion = "3.9"
pythonVersion = "3.10"
typeCheckingMode = "strict"
# Already covered by tests and careful import ordering:
reportImportCycles = false
Expand All @@ -85,7 +85,7 @@ reportPrivateUsage = false


[tool.ruff]
target-version = "py39"
target-version = "py310"

[tool.ruff.lint]
select = ["ALL"]
Expand All @@ -112,11 +112,11 @@ keep-runtime-typing = true

[tool.tox]
env_list = [
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
"3.14",
"docs",
"mypy",
"pyright",
Expand Down
9 changes: 3 additions & 6 deletions src/brreg/_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from typing import Optional


class BrregError(Exception):
"""Top-level exception.

Expand All @@ -16,9 +13,9 @@ def __init__(
self,
msg: str,
*,
method: Optional[str],
url: Optional[str],
status_code: Optional[int],
method: str | None,
url: str | None,
status_code: int | None,
) -> None:
super().__init__(f"REST API exception: {msg}")
self.method = method
Expand Down
14 changes: 7 additions & 7 deletions src/brreg/enhetsregisteret/_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Generator
from contextlib import contextmanager
from types import TracebackType
from typing import Any, Optional
from typing import Any

import httpx

Expand Down Expand Up @@ -48,9 +48,9 @@ def __enter__(self) -> "Client":

def __exit__(
self,
exc_type: Optional[type[BaseException]] = None,
exc_value: Optional[BaseException] = None,
traceback: Optional[TracebackType] = None,
exc_type: type[BaseException] | None = None,
exc_value: BaseException | None = None,
traceback: TracebackType | None = None,
) -> None:
self.close()

Expand Down Expand Up @@ -78,7 +78,7 @@ def close(self) -> None:
def get_enhet(
self,
organisasjonsnummer: Organisasjonsnummer,
) -> Optional[Enhet]:
) -> Enhet | None:
"""Get :class:`Enhet` given an organization number."""
orgnr = OrganisasjonsnummerValidator.validate_python(organisasjonsnummer)
with error_handler():
Expand All @@ -99,7 +99,7 @@ def get_enhet(
def get_underenhet(
self,
organisasjonsnummer: Organisasjonsnummer,
) -> Optional[Underenhet]:
) -> Underenhet | None:
"""Get :class:`Underenhet` given an organization number."""
orgnr = OrganisasjonsnummerValidator.validate_python(organisasjonsnummer)
with error_handler():
Expand Down Expand Up @@ -184,7 +184,7 @@ def error_handler() -> Generator[None, Any, None]:
try:
yield
except httpx.HTTPError as exc:
response: Optional[httpx.Response] = getattr(exc, "response", None)
response: httpx.Response | None = getattr(exc, "response", None)
raise BrregRestError(
str(exc),
method=(exc.request.method if exc.request else None),
Expand Down
19 changes: 5 additions & 14 deletions src/brreg/enhetsregisteret/_pagination.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
from collections.abc import Iterator
from typing import (
Callable,
Generic,
Optional,
TypeVar,
)

from pydantic import (
AliasPath,
BaseModel,
Field,
)
from collections.abc import Callable, Iterator
from typing import Generic, TypeVar

from pydantic import AliasPath, BaseModel, Field

from brreg.enhetsregisteret._queries import Query
from brreg.enhetsregisteret._responses import Enhet, Underenhet
Expand Down Expand Up @@ -75,7 +66,7 @@ def __init__(
# Expose the empty first page, even if it says the totalt number of pages is 0.
self.page_numbers = range(max(1, page.total_pages))

def get_page(self, page_number: int) -> Optional[Page[T]]:
def get_page(self, page_number: int) -> Page[T] | None:
"""Get a page by its 0-indexed page number."""
if page_number not in self.page_numbers:
return None
Expand Down
Loading