Skip to content

52/model subtypes dont typecheck #55

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

Merged

Conversation

syastrov
Copy link
Contributor

No description provided.

@syastrov
Copy link
Contributor Author

syastrov commented Mar 24, 2019

The rather annoying errors that I had to add ignores for:
Definition of ("_default_manager" or "objects") in base class "Parent1" is incompatible with definition in base class "Parent2"
seem to be a mypy issue. I have made a PR to mypy which fixes them: python/mypy#6585

I'll keep on adding ignores for now...

@mkurnikov mkurnikov closed this Mar 25, 2019
@mkurnikov mkurnikov reopened this Mar 25, 2019
@syastrov syastrov force-pushed the 52/model_subtypes_dont_typecheck branch from 59aa6e4 to 1d737a0 Compare March 28, 2019 07:07
…h other due to fallback_to_any = True. Fixes typeddjango#52.

- Added a stub for __getstate__ to Model.
- Added a stub for clean() to Model.
- Correct arg type for sort_dependencies so they are covariant (Iterable rather than List).

Test ignores:
- Added some test ignores in cases where a model inherits from 2 different base models.
- Added some test ignores for cases that MyPy flags as errors due to variable redefinitions or imports that are incompatible types.
@syastrov syastrov force-pushed the 52/model_subtypes_dont_typecheck branch from 1d737a0 to 70a92fd Compare March 28, 2019 07:09
class Child1(Parent1, Parent2):

# TODO: Remove the 2 expected errors on the next line once mypy issue https://github.com/python/mypy/issues/2619 is resolved:
class Child1(Parent1, Parent2): # E: Definition of "objects" in base class "Parent1" is incompatible with definition in base class "Parent2" # E: Definition of "_default_manager" in base class "Parent1" is incompatible with definition in base class "Parent2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change it into multiline error? This is the example how it supported in the test plugin
https://github.com/mkurnikov/pytest-mypy-plugins/blob/master/pytest_mypy/tests/e2e/output.test#L41

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mkurnikov mkurnikov merged commit 71fb043 into typeddjango:master Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants