Repository: frenck/python-demetriek (language: python)

Issue:
Replace pydantic with mashumaro
# Proposed Changes

This PR exchanges the pydantic dependency with [mashumaro](https://github.com/Fatal1ty/mashumaro). This is due to the fact that the version of pydantic used is not anymore supported, and a migration was not accepted (see https://github.com/frenck/python-demetriek/pull/531)

I've taken into account the following PRs from the author as references on how to do the migration:

- https://github.com/frenck/python-elgato/pull/938
- https://github.com/frenck/python-tailscale/pull/443

# Changelog

I had to to some unrelated changes to get the pipeline to run through, due to some library upgrades that now fail on CI. Since the content is not crazy big, I decided to add them to the same PR, but let me know if I should make a separate PR instead. Here is the list of changes:

- Exchanged pydantic to mashumaro, like it was done on the other repositories

# Discussion

As far as tests are concerned, the changes should work out of the box, but I do not have one of those devices to test it. If there is a way to have simulated APIs or there are test cases that should be covered, let me know.

# Related Issues

For the pydantic upgrade in HA, this change is necessary:

- https://github.com/home-assistant/core/issues/99218



Discussion / hints:

> # Changelog
> I had to to some unrelated changes to get the pipeline to run through, due to some library upgrades that now fail on CI. 
> Since the content is not crazy big, I decided to add them to the same PR, but let me know if I should make a separate PR instead. 

I'd definitely say make each of these changes into separate PRs for each change mentioned (CI fixes, async timeout, grammar/spelling fixes,  linting fixes, etc)


I moved the unrelated changes to get the pipelines to run to other PRs:

- File had to be reformatted with latest ruff for the CI workflow to succeed, so some styling changed here and there, like spacings between and within comments.: https://github.com/frenck/python-demetriek/pull/742
- On the file `.github/CODE_OF_CONDUCT.md`, the codespell pre-commit was failing for the word `socio-economic`, so I changed it to `socioeconomic`. Seems like the [word is not hyphenated](https://www.collinsdictionary.com/de/worterbuch/englisch/socioeconomic): https://github.com/frenck/python-demetriek/pull/743
- On CI linting workflow, the command `poetry run ruff .` was changed to `poetry run ruff check .`: https://github.com/frenck/python-demetriek/pull/741
- I had to adapt the upload of artifacts because of https://github.com/actions/upload-artifact/issues/602, since the `.coverage` file would not be uploaded anymore without the `include-hidden-files` option.: https://github.com/frenck/python-demetriek/pull/744
- `async_timeout.timeout` has been replaced by `asyncio.timeouts.timeout`. See that the [original library is not deprecated](https://pypi.org/project/async-timeout/), and they recommend you to use asyncio instead. Since this library only supports Python 3.11 and above, the dependency is completely dropped (wasn't on the `pyproject.toml` either way): https://github.com/frenck/python-demetriek/pull/745

Those can be made first and I'll rebase this branch once that is done. I left safety dependency removal in this PR because it's required to be removed for pydantic to be completely dropped.

Fix patch:
diff --git a/examples/ruff.toml b/examples/ruff.toml
index 2eb42d98..5d27c1f8 100644
--- a/examples/ruff.toml
+++ b/examples/ruff.toml
@@ -1,6 +1,7 @@
 # This extend our general Ruff rules specifically for the examples
 extend = "../pyproject.toml"
 
+[lint]
 extend-ignore = [
   "T201", # Allow the use of print() in examples
 ]
diff --git a/pyproject.toml b/pyproject.toml
index f8a32cfc..cf86a4c3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -141,7 +141,7 @@ max-attributes = 20
 addopts = "--cov"
 asyncio_mode = "auto"
 
-[tool.ruff]
+[tool.ruff.lint]
 ignore = [
   "ANN101", # Self... explanatory
   "ANN102", # cls... just as annoying as ANN101
@@ -153,17 +153,17 @@ ignore = [
 ]
 select = ["ALL"]
 
-[tool.ruff.flake8-pytest-style]
+[tool.ruff.lint.flake8-pytest-style]
 fixture-parentheses = false
 mark-parentheses = false
 
-[tool.ruff.isort]
+[tool.ruff.lint.isort]
 known-first-party = ["demetriek"]
 
-[tool.ruff.mccabe]
+[tool.ruff.lint.mccabe]
 max-complexity = 25
 
-[tool.ruff.per-file-ignores]
+[tool.ruff.lint.per-file-ignores]
 "src/demetriek/models.py" = ["TCH002", "TCH003"]
 
 [build-system]


Test patch:
diff --git a/tests/ruff.toml b/tests/ruff.toml
index b346c562..6a68b95a 100644
--- a/tests/ruff.toml
+++ b/tests/ruff.toml
@@ -1,6 +1,7 @@
 # This extend our general Ruff rules specifically for tests
 extend = "../pyproject.toml"
 
+[lint]
 extend-select = [
   "PT", # Use @pytest.fixture without parentheses
 ]