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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"
- run: pip install nox==2024.4.15 poetry==1.8.3
- run: nox --python 3.12
- run: nox --python 3.13
- run: poetry build
- run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodejs 21.1.0
poetry 1.8.3
python 3.12 3.11 3.10 3.9 3.8 3.13.0rc1
python 3.13 3.12 3.11 3.10 3.9
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Norwegian Business Registry, [Brønnøysundregistrene](https://www.brreg.no/).

## Installation

The library requires Python 3.8 or newer.
The library requires Python 3.9 or newer.

The library can be installed from [PyPI](https://pypi.org/project/brreg/):

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Norwegian Business Registry, `Brønnøysundregistrene <https://www.brreg.no/>`_.
Installation
============

The library requires Python 3.8 or newer.
The library requires Python 3.9 or newer.

The library can be installed from `PyPI <https://pypi.org/project/brreg/>`_:

Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

locations = ["docs/conf.py", "noxfile.py", "src", "tests"]

supported_pythons = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
docs_python = "3.12"
supported_pythons = ["3.9", "3.10", "3.11", "3.12", "3.13"]
docs_python = "3.13"


@nox.session(python=supported_pythons)
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.8.0"
python = "^3.9.0"
httpx = ">= 0.24"
pydantic = ">= 2"
typing-extensions = ">= 4.4.0"

[tool.poetry.group.dev.dependencies]
nox = "^2024.4.15"
Expand Down Expand Up @@ -72,7 +71,7 @@ module = "brreg.*"
disallow_untyped_defs = true

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

[tool.ruff.lint]
select = ["ALL"]
Expand Down Expand Up @@ -100,7 +99,7 @@ convention = "google"
keep-runtime-typing = true

[tool.pyright]
pythonVersion = "3.8"
pythonVersion = "3.9"
venvPath = "."
venv = ".venv"
typeCheckingMode = "strict"
Expand Down
7 changes: 4 additions & 3 deletions src/brreg/enhetsregisteret/_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections.abc import Generator
from contextlib import contextmanager
from types import TracebackType
from typing import Any, Generator, List, Optional, Type
from typing import Any, Optional

import httpx

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

def __exit__(
self,
exc_type: Optional[Type[BaseException]] = None,
exc_type: Optional[type[BaseException]] = None,
exc_value: Optional[BaseException] = None,
traceback: Optional[TracebackType] = None,
) -> None:
Expand Down Expand Up @@ -120,7 +121,7 @@ def get_underenhet(
def get_roller(
self,
organisasjonsnummer: Organisasjonsnummer,
) -> List[RolleGruppe]:
) -> list[RolleGruppe]:
"""Get :class:`Enhet` given an organization number."""
orgnr = OrganisasjonsnummerValidator.validate_python(organisasjonsnummer)
with error_handler():
Expand Down
12 changes: 5 additions & 7 deletions src/brreg/enhetsregisteret/_pagination.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from collections.abc import Iterator
from typing import (
Callable,
Dict,
Generic,
Iterator,
List,
Optional,
TypeVar,
)
Expand Down Expand Up @@ -31,7 +29,7 @@ class Page(BaseModel, Generic[T]):
"""The fields here are available on all page objects."""

#: The items on this page.
items: List[T]
items: list[T]

#: The number of elements on this page.
page_size: int = Field(
Expand Down Expand Up @@ -59,7 +57,7 @@ class Cursor(Generic[T, Q]):

_operation: Callable[[Q], "Cursor[T, Q]"]
_query: Q
_pages: Dict[int, Page[T]]
_pages: dict[int, Page[T]]
_current_page_number: int

#: Iterate over all page numbers in this cursor.
Expand Down Expand Up @@ -111,7 +109,7 @@ def items(self) -> Iterator[T]:
class EnhetPage(Page[Enhet]):
"""Response type for enhet search."""

items: List[Enhet] = Field(
items: list[Enhet] = Field(
default_factory=list,
validation_alias=AliasPath("_embedded", "enheter"),
)
Expand All @@ -120,7 +118,7 @@ class EnhetPage(Page[Enhet]):
class UnderenhetPage(Page[Underenhet]):
"""Response type for underenhet search."""

items: List[Underenhet] = Field(
items: list[Underenhet] = Field(
default_factory=list,
validation_alias=AliasPath("_embedded", "underenheter"),
)
22 changes: 11 additions & 11 deletions src/brreg/enhetsregisteret/_responses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime as dt
from typing import List, Optional
from typing import Optional

from pydantic import (
BaseModel,
Expand Down Expand Up @@ -33,7 +33,7 @@ class Adresse(BaseModel):
model_config = ConfigDict(alias_generator=to_camel)

#: Adresse
adresse: List[Optional[str]] = Field(default_factory=list)
adresse: list[Optional[str]] = Field(default_factory=list)

#: Postnummer
postnummer: Optional[str] = None
Expand Down Expand Up @@ -121,7 +121,7 @@ class Enhet(BaseModel):

#: Enheter som i utgangspunktet ikke er mva-pliktig, kan søke om frivillig
#: registrering i Merverdiavgiftsregisteret
frivillig_mva_registrert_beskrivelser: List[str] = Field(default_factory=list)
frivillig_mva_registrert_beskrivelser: list[str] = Field(default_factory=list)

#: Næringskode 1
naeringskode1: Optional[Naering] = None
Expand Down Expand Up @@ -184,10 +184,10 @@ class Enhet(BaseModel):
vedtektsdato: DateOrNone = None

#: Enhetens formål
vedtektsfestet_formaal: List[str] = Field(default_factory=list)
vedtektsfestet_formaal: list[str] = Field(default_factory=list)

#: Enhetens aktivitet
aktivitet: List[str] = Field(default_factory=list)
aktivitet: list[str] = Field(default_factory=list)

#: Nedleggelsesdato for underenheten
nedleggelsesdato: DateOrNone = None
Expand Down Expand Up @@ -228,7 +228,7 @@ class Underenhet(BaseModel):

#: Underenheter som i utgangspunktet ikke er mva-pliktig, kan søke om
#: frivillig registrering i Merverdiavgiftsregisteret
frivillig_mva_registrert_beskrivelser: List[str] = Field(default_factory=list)
frivillig_mva_registrert_beskrivelser: list[str] = Field(default_factory=list)

#: Næringskode 1
naeringskode1: Optional[Naering] = None
Expand Down Expand Up @@ -316,7 +316,7 @@ class RolleEnhet(BaseModel):
organisasjonsform: Organisasjonsform

#: Enhetens navn
navn: List[str] = Field(default_factory=list)
navn: list[str] = Field(default_factory=list)

#: Hvorvidt enheten er slettet
er_slettet: bool
Expand All @@ -329,7 +329,7 @@ class RolleFullmektig(BaseModel):
navn: Optional[str] = None

#: Adresser/adresselinjer knyttet til fullmektig
adresse: List[str] = Field(default_factory=list)
adresse: list[str] = Field(default_factory=list)


class Rolle(BaseModel):
Expand All @@ -354,7 +354,7 @@ class Rolle(BaseModel):
fratraadt: bool

#: Liste over fullmektige
fullmektige: List[RolleFullmektig] = Field(default_factory=list)
fullmektige: list[RolleFullmektig] = Field(default_factory=list)

#: Rekkefølgen på rollen i gruppen
rekkefolge: Optional[int] = None
Expand All @@ -380,11 +380,11 @@ class RolleGruppe(BaseModel):
sist_endret: dt.date

#: Liste med alle rollene i gruppen
roller: List[Rolle]
roller: list[Rolle]


class RollerResponse(BaseModel):
model_config = ConfigDict(alias_generator=to_camel)

#: Liste med rollegrupper knyttet til enheten
rollegrupper: List[RolleGruppe]
rollegrupper: list[RolleGruppe]
5 changes: 2 additions & 3 deletions src/brreg/enhetsregisteret/_types.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import datetime as dt
from typing import List, Optional, TypeVar
from typing import Annotated, Optional, TypeVar

from pydantic import (
BeforeValidator,
Field,
PlainSerializer,
TypeAdapter,
)
from typing_extensions import Annotated

T = TypeVar("T")

# A list that serializes to a comma-separated string.
CommaList = Annotated[
List[T],
list[T],
PlainSerializer(
lambda v: ",".join(v),
return_type=str,
Expand Down