Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(pre-commit.ci): autoupdate #263

Merged
merged 2 commits into from
Nov 21, 2024
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ ci:

repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.19
rev: v0.23
hooks:
- id: validate-pyproject

- repo: https://github.com/crate-ci/typos
rev: v1.24.5
rev: typos-dict-v0.11.35
hooks:
- id: typos
args: [--force-exclude] # omit --write-changes

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.7.4
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.13.0
hooks:
- id: mypy
exclude: ^tests|^docs|_napari_plugin|widgets
additional_dependencies:
- pydantic>=2
- pydantic>=2.10
- pydantic-compat
- xsdata==24.2.1
- Pint
Expand Down
4 changes: 3 additions & 1 deletion src/ome_autogen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ def _disp_type(obj: Any) -> str:
else:
_fields = [
f"{k}: {_disp_type(v.annotation)}"
for k, v in sorted(m.model_fields.items())
# this type ignore indicates something that may break in pydantic 3
# but for now, it's confusing and I think it's an error
for k, v in sorted(m.model_fields.items()) # type: ignore
]
if _fields:
module += CLASS.format(
Expand Down
4 changes: 2 additions & 2 deletions src/ome_types/_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def _get_ns_elem(elem: ET._Element | AnyElementTree) -> str:
"""Get namespace from an element or element tree."""
root = elem.getroot() if hasattr(elem, "getroot") else elem
# return root.nsmap[root.prefix] this only works for lxml
return root.tag.split("}", 1)[0].lstrip("{")
return str(root.tag).split("}", 1)[0].lstrip("{")


def _get_ns_file(source: FileLike) -> str:
Expand All @@ -582,7 +582,7 @@ def _get_root_ome_type(xml: FileLike | AnyElementTree) -> type[OMEType]:
if hasattr(xml, "seek"):
xml.seek(0)
_, root = next(ET.iterparse(xml, events=("start",)))
localname = cast("ET._Element", root).tag.rsplit("}", 1)[-1]
localname = str(root.tag).rsplit("}", 1)[-1]

if hasattr(xml, "seek"):
xml.seek(0)
Expand Down
5 changes: 3 additions & 2 deletions src/ome_types/_pydantic_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def field_type(field: FieldInfo) -> Any:
return field.annotation

def field_regex(obj: type[BaseModel], field_name: str) -> str | None:
field_info = obj.model_fields[field_name]
# typing is incorrect at the moment, but may indicate breakage in pydantic 3
field_info = obj.model_fields[field_name] # type: ignore [index]
meta = field_info.json_schema_extra or {}
# if a "metadata" key exists... use it.
# After pydantic-compat 0.2, this is where it will be.
Expand All @@ -30,7 +31,7 @@ def field_regex(obj: type[BaseModel], field_name: str) -> str | None:
return None

def get_default(f: FieldInfo) -> Any:
return f.get_default(call_default_factory=True)
return f.get_default(call_default_factory=True, validated_data={})

else:
from pydantic.color import Color as Color # type: ignore [no-redef]
Expand Down
4 changes: 2 additions & 2 deletions src/xsdata_pydantic_basemodel/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class AnyElement(PydanticCompatMixin, BaseModel):
tail: Optional[str] = Field(default=None)
children: List["AnyElement"] = Field(
default_factory=list,
metadata={"type": XmlType.WILDCARD}, # type: ignore [call-arg]
metadata={"type": XmlType.WILDCARD}, # type: ignore [call-arg,call-overload]
)
attributes: Dict[str, str] = Field(
default_factory=dict,
metadata={"type": XmlType.ATTRIBUTES}, # type: ignore [call-arg]
metadata={"type": XmlType.ATTRIBUTES}, # type: ignore [call-arg,call-overload]
)

model_config: ClassVar["ConfigDict"] = {"arbitrary_types_allowed": True}
Expand Down
2 changes: 1 addition & 1 deletion src/xsdata_pydantic_basemodel/pydantic_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ def dataclass_fields(obj: type[M]) -> tuple[dc.Field, ...]:
"""Return a tuple of dataclass fields for the given pydantic model class."""
return tuple(
_pydantic_field_to_dataclass_field(name, f)
for name, f in obj.model_fields.items()
for name, f in obj.model_fields.items() # type: ignore
)
Loading