From 5eec756dfda55e5c0c4151b34d8d5032d661bcfc Mon Sep 17 00:00:00 2001 From: Frank Hoffmann <15r10nk-git@polarbit.de> Date: Sun, 12 Jan 2025 20:29:55 +0100 Subject: [PATCH] fix: raised required dirty-equal to 0.9.0 --- .github/workflows/ci.yml | 2 +- .../20250112_213028_15r10nk-git_pydantic_ai_fixes.md | 3 +++ docs/eq_snapshot.md | 7 +++++++ pyproject.toml | 10 ++++++---- src/inline_snapshot/_code_repr.py | 3 ++- tests/test_dirty_equals.py | 2 ++ 6 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 changelog.d/20250112_213028_15r10nk-git_pydantic_ai_fixes.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da22c03c..cb61dd38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: python-version: ${{matrix.python-version}} - run: | - uv run ${{matrix.extra_deps}} --extra black -m ${{ matrix.os == 'ubuntu-latest' && 'coverage run -m' || '' }} pytest -n=auto -vv + uv run ${{matrix.extra_deps}} --extra black --extra dirty-equals -m ${{ matrix.os == 'ubuntu-latest' && 'coverage run -m' || '' }} pytest -n=auto -vv - run: | uv run -m coverage combine mv .coverage .coverage.${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} diff --git a/changelog.d/20250112_213028_15r10nk-git_pydantic_ai_fixes.md b/changelog.d/20250112_213028_15r10nk-git_pydantic_ai_fixes.md new file mode 100644 index 00000000..fdad544f --- /dev/null +++ b/changelog.d/20250112_213028_15r10nk-git_pydantic_ai_fixes.md @@ -0,0 +1,3 @@ +### Added + +- added the optional `inline-snapshot[dirty-equals]` dependency to depend on the dirty-equals version which works in combination with inline-snapshot. diff --git a/docs/eq_snapshot.md b/docs/eq_snapshot.md index c05bdff5..b9ca92f0 100644 --- a/docs/eq_snapshot.md +++ b/docs/eq_snapshot.md @@ -120,6 +120,7 @@ Example: The date can be replaced with the [dirty-equals](https://dirty-equals.helpmanual.io/latest/) expression `IsDatetime()`. + Example: === "using IsDatetime()" @@ -195,6 +196,12 @@ Example: ) ``` +!!! note + Use the optional *dirty-equals* dependency to install the version that works best in combination with inline-snapshot. + ``` sh + pip install inline-snapshot[dirty-equals] + ``` + ### Is(...) `Is()` can be used to put runtime values inside snapshots. diff --git a/pyproject.toml b/pyproject.toml index 9959c505..ad41fee3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,9 @@ black = [ "black>=23.3.0", "click>=8.1.4" ] +dirty-equals =[ + "dirty-equals>=0.9.0", +] [dependency-groups] dev = [ @@ -54,7 +57,6 @@ dev = [ "coverage[toml]>=7.6.1", "coverage-enable-subprocess>=1.0", "pytest>=8", - "dirty-equals>=0.7.0", "attrs>=24.3.0", "pydantic>=1", ] @@ -134,8 +136,8 @@ matrix.extra-deps.dependencies = [ [tool.hatch.envs.hatch-test] extra-dependencies = [ - "inline-snapshot[black]", - "dirty-equals>=0.7.0", + "inline-snapshot[black,dirty-equals]", + "dirty-equals>=0.9.0", "hypothesis>=6.75.5", "mypy>=1.2.0", "pyright>=1.1.359", @@ -153,7 +155,7 @@ cov-report=["coverage report","coverage html"] [tool.hatch.envs.types] extra-dependencies = [ - "inline-snapshot[black]", + "inline-snapshot[black,dirty-equals]", "mypy>=1.0.0", "pytest", "hypothesis>=6.75.5", diff --git a/src/inline_snapshot/_code_repr.py b/src/inline_snapshot/_code_repr.py index cf94a953..3b5252bc 100644 --- a/src/inline_snapshot/_code_repr.py +++ b/src/inline_snapshot/_code_repr.py @@ -88,7 +88,8 @@ def mocked_code_repr(obj): def value_code_repr(obj): - if not type(obj) == type(obj): + if not type(obj) == type(obj): # pragma: no cover + # this was caused by https://github.com/samuelcolvin/dirty-equals/issues/104 # dispatch will not work in cases like this return ( f"HasRepr({repr(type(obj))}, '< type(obj) can not be compared with == >')" diff --git a/tests/test_dirty_equals.py b/tests/test_dirty_equals.py index 1bc897a3..a5e7b4fc 100644 --- a/tests/test_dirty_equals.py +++ b/tests/test_dirty_equals.py @@ -1,7 +1,9 @@ +import pytest from inline_snapshot._inline_snapshot import snapshot from inline_snapshot.testing._example import Example +@pytest.mark.xfail def test_dirty_equals_repr(): Example( """\