Skip to content

Commit

Permalink
Update pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tefra committed Dec 6, 2024
1 parent aa6e768 commit 0b1d160
Show file tree
Hide file tree
Showing 120 changed files with 758 additions and 802 deletions.
10 changes: 4 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ repos:
- id: end-of-file-fixer
- id: debug-statements
- repo: https://github.com/crate-ci/typos
rev: v1.27.0
rev: v1.28.2
hooks:
- id: typos
exclude: ^tests/|.xsd|xsdata/models/datatype.py$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.2
hooks:
- id: ruff
args: [ --fix, --show-fixes]
Expand All @@ -31,11 +31,9 @@ repos:
- types-docutils
- types-toposort
args: [ "--check-untyped-defs", "--ignore-missing-imports" ]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.4.2
hooks:
- id: prettier
additional_dependencies:
- [email protected]
types_or: [markdown]
args: [--prose-wrap=always, --print-width=88]
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ license-files = ["LICENSE"]
version = {attr = "xsdata.__version__"}

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

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -114,8 +114,6 @@ select = [
]

ignore = [
"ANN101",
"ANN102",
"ANN201",
"ANN202",
"ANN204",
Expand All @@ -133,6 +131,7 @@ ignore = [

[tool.ruff.lint.per-file-ignores]
"**/{tests}/*" = ["ANN001", "ANN002", "ANN003", "E501", "B018", "D"]
"tests/formats/dataclass/cases/**" = ["UP"]
"**/utils/testing.py" = ["D"]
"docs/*" = ["D"]

Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/handlers/test_vacuum_inner_classes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Generator
from collections.abc import Generator

from xsdata.codegen.handlers import VacuumInnerClasses
from xsdata.models.enums import DataType
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/mappers/test_definitions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Generator
from collections.abc import Generator
from unittest import mock

from xsdata.codegen.mappers import DefinitionsMapper
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/mappers/test_dtd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Iterator
from collections.abc import Iterator
from unittest import mock

from xsdata.codegen.mappers import DtdMapper
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/mappers/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Iterator
from types import GeneratorType
from typing import Iterator
from unittest import mock

from xsdata.codegen.mappers import SchemaMapper
Expand Down
3 changes: 1 addition & 2 deletions tests/codegen/models/test_codegen.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import unittest
from dataclasses import dataclass
from typing import List

from xsdata.codegen.models import CodegenModel


@dataclass
class Foo(CodegenModel):
bar: List["Bar"]
bar: list["Bar"]

@dataclass
class Bar(CodegenModel):
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Generator
from collections.abc import Generator
from unittest import mock

from xsdata.codegen.exceptions import CodegenError
Expand Down
4 changes: 2 additions & 2 deletions tests/codegen/test_writer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Iterator
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Iterator, List
from unittest import mock

from xsdata.codegen.exceptions import CodegenError
Expand All @@ -13,7 +13,7 @@


class NoneGenerator(AbstractGenerator):
def render(self, classes: List[Class]) -> Iterator[GeneratorResult]:
def render(self, classes: list[Class]) -> Iterator[GeneratorResult]:
pass


Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
from typing import Type

from lxml import etree

Expand All @@ -13,7 +12,7 @@
from xsdata.formats.dataclass.serializers.config import SerializerConfig


def validate_bindings(schema: Path, clazz: Type):
def validate_bindings(schema: Path, clazz: type):
__tracebackhide__ = True

sample = schema.parent.joinpath("sample.xml")
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/artists/metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import List, Optional, Union
from typing import Optional, Union

from xsdata.models.datatype import XmlDate, XmlPeriod

Expand Down Expand Up @@ -111,7 +111,7 @@ class Meta:
name = "ipi-list"
namespace = "http://musicbrainz.org/ns/mmd-2.0#"

ipi: List[str] = field(
ipi: list[str] = field(
default_factory=list,
metadata={
"type": "Element",
Expand All @@ -126,7 +126,7 @@ class Meta:
name = "isni-list"
namespace = "http://musicbrainz.org/ns/mmd-2.0#"

isni: List[str] = field(
isni: list[str] = field(
default_factory=list,
metadata={
"type": "Element",
Expand Down Expand Up @@ -207,7 +207,7 @@ class Meta:
"required": True,
},
)
alias: List[Alias] = field(
alias: list[Alias] = field(
default_factory=list,
metadata={
"type": "Element",
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/books/books.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import List, Optional
from typing import Optional

from xsdata.models.datatype import XmlDate

Expand Down Expand Up @@ -87,7 +87,7 @@ class BookForm:

@dataclass
class BooksForm:
book: List[BookForm] = field(
book: list[BookForm] = field(
default_factory=list,
metadata={
"type": "Element",
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/compound/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import List, Union
from typing import Union


@dataclass
Expand Down Expand Up @@ -35,7 +35,7 @@ class Root:
class Meta:
name = "root"

alpha_or_bravo_or_charlie: List[Union[Alpha, Bravo, List[str]]] = field(
alpha_or_bravo_or_charlie: list[Union[Alpha, Bravo, list[str]]] = field(
default_factory=list,
metadata={
"type": "Elements",
Expand All @@ -50,7 +50,7 @@ class Meta:
},
{
"name": "charlie",
"type": List[str],
"type": list[str],
"namespace": "",
"default_factory": list,
"tokens": True,
Expand Down
10 changes: 5 additions & 5 deletions tests/fixtures/dtd/models/complete_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
from enum import Enum
from typing import List, Optional
from typing import Optional


@dataclass
Expand Down Expand Up @@ -60,7 +60,7 @@ class Title:

@dataclass
class Tags:
tag: List[Tag] = field(
tag: list[Tag] = field(
default_factory=list,
metadata={
"name": "Tag",
Expand Down Expand Up @@ -100,14 +100,14 @@ class Post:
"required": True,
},
)
origin: List[Origin] = field(
origin: list[Origin] = field(
default_factory=list,
metadata={
"name": "Origin",
"type": "Element",
},
)
source: List[Source] = field(
source: list[Source] = field(
default_factory=list,
metadata={
"name": "Source",
Expand Down Expand Up @@ -142,7 +142,7 @@ class Post:

@dataclass
class Blog:
post: List[Post] = field(
post: list[Post] = field(
default_factory=list,
metadata={
"name": "Post",
Expand Down
2 changes: 0 additions & 2 deletions tests/fixtures/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from typing import Union
from xml.etree.ElementTree import QName

from xsdata.utils.constants import return_true

__NAMESPACE__ = "xsdata"


Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/primer/order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
from decimal import Decimal
from typing import List, Optional
from typing import Optional

from xsdata.models.datatype import XmlDate

Expand Down Expand Up @@ -74,7 +74,7 @@ class Meta:

@dataclass
class Items:
item: List["Items.Item"] = field(
item: list["Items.Item"] = field(
default_factory=list,
metadata={
"type": "Element",
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/series/series.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import List, Optional
from typing import Optional

from xsdata.models.datatype import XmlDate

Expand Down Expand Up @@ -119,7 +119,7 @@ class Meta:
"required": True,
},
)
days: List[str] = field(
days: list[str] = field(
default_factory=list,
metadata={
"type": "Element",
Expand Down Expand Up @@ -231,7 +231,7 @@ class Meta:
"required": True,
},
)
genres: List[str] = field(
genres: list[str] = field(
default_factory=list,
metadata={
"type": "Element",
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/stripe/models/balance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import Optional, Tuple
from typing import Optional


@dataclass(order=True, frozen=True)
Expand Down Expand Up @@ -113,14 +113,14 @@ class Meta:
"required": True,
},
)
available: Tuple[Available, ...] = field(
available: tuple[Available, ...] = field(
default_factory=tuple,
metadata={
"type": "Element",
"min_occurs": 1,
},
)
connect_reserved: Tuple[ConnectReserved, ...] = field(
connect_reserved: tuple[ConnectReserved, ...] = field(
default_factory=tuple,
metadata={
"type": "Element",
Expand All @@ -134,7 +134,7 @@ class Meta:
"required": True,
},
)
pending: Tuple[Pending, ...] = field(
pending: tuple[Pending, ...] = field(
default_factory=tuple,
metadata={
"type": "Element",
Expand Down
10 changes: 5 additions & 5 deletions tests/fixtures/wrapper/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import List, Optional
from typing import Optional

__NAMESPACE__ = "xsdata"

Expand All @@ -25,7 +25,7 @@ class Meta:
name = "bravos"
namespace = "xsdata"

bravo: List[int] = field(
bravo: list[int] = field(
default_factory=list,
metadata={
"type": "Element",
Expand Down Expand Up @@ -60,7 +60,7 @@ class Meta:
name = "charlies"
namespace = "xsdata"

charlie: List[Charlie] = field(
charlie: list[Charlie] = field(
default_factory=list,
metadata={
"type": "Element",
Expand All @@ -83,15 +83,15 @@ class Meta:
"required": True,
},
)
bravo: List[int] = field(
bravo: list[int] = field(
default_factory=list,
metadata={
"wrapper": "bravos",
"type": "Element",
"min_occurs": 1,
},
)
charlie: List[Charlie] = field(
charlie: list[Charlie] = field(
default_factory=list,
metadata={
"wrapper": "charlies",
Expand Down
Loading

0 comments on commit 0b1d160

Please sign in to comment.