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
Fix broken user types after typing-inspect 0.8.0 #207
Conversation
Since the recent release of `typing-inspect` 0.8.0, it's `is_new_type()` check expects the new type to come from the `typing` or `typing_extensions` module. When using local `NewType`, this condition isn't met. The fix makes use of the `typing.NewType` and only adds the `marshmallow_dataclass` specific fields.
I made the change from github as it seemed pretty straightforward, but oh my, was I wrong. When running the local commit checks i get:
Adding some |
FYI, I have no clue why the 3.8 test failed here. Can't reproduce at my place (Fedora 36) with: python3.8 -m venv venv38
. venv38/bin/activate
pip install --upgrade pip setuptools
pip install '.[dev]'
pytest
|
Investigating the error a bit I found it could be related to the way how the package is installed for the test:
This differs from the contributing guide which has only:
Playing with the args, found the |
Why is |
@lovasoa It may as well be, when you're running local tests on your workstation (so you don't have to But the problem here is more mundane, because when there's |
Sorry, I just couldn't let it go :) It seems mypy just has some trouble figuring out the path to the package when it's installed with PYTHONPATH=$(pwd) pytest or maybe even better with: python -m pytest which also works well. Maybe the last one is the most foolproof (it's also one of the documented ways). |
Personally I don't think editable installs should be used on CI since that can miss things like data files not getting installed in the package (I don't believe that's an issue here though). |
This prevents issues when marshmallow_dataclass is installed in editable mode. (See lovasoa#209, lovasoa#207.)
This prevents issues when marshmallow_dataclass is installed in editable mode. (See lovasoa#209, lovasoa#207.)
…t 0.8.0 This is cherry-picks PR#207 by @vit-zikmund
* Explicitly set PYTHONPATH=. in mypy tests This prevents issues when marshmallow_dataclass is installed in editable mode. (See #209, #207.) * Don't fail tests upon warnings from external packages. E.g. marshmallow<3.15 generates a deprecation warning from distutils. There's no reason that should cause a test failure for us. * Update black target-version config. I have no idea whether this actually affects anything, but might as well keep it up-to-date. * Fix typing of Union._serialize parameter This tracks a change in type of the `attr` parameter to `Field._serialize` made in marshmallow 3.18.0. Here we also switch to using keyword args to typeguard.check_type in an attempt to protect against upcoming [changes in its signature](https://typeguard.readthedocs.io/en/latest/api.html#typeguard.check_type). * Cherry-pick PR #207: Fix broken user types after typing-inspect 0.8.0 This is cherry-picks PR#207 by @vit-zikmund
I have cherry-picked this into #211 which has been merged to master... closing. And thank you! |
Since the recent release of
typing-inspect
0.8.0, it'sis_new_type()
check expects the new type to come from thetyping
ortyping_extensions
module. When using localNewType
, this condition isn't met.The fix makes use of the
typing.NewType
and only adds themarshmallow_dataclass
specific fields.