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

Support dataclass inference for pydantic.dataclasses. #1178

Merged
merged 1 commit into from
Sep 17, 2021

Conversation

david-yz-liu
Copy link
Contributor

Steps

  • For new features or bug fixes, add a ChangeLog entry describing what your PR does.
  • Write a good description on what the PR does.

Description

Hello, sorry for the delay on this one, it's been a bit hectic at work. Thanks @DanielNoord for the comment pylint-dev/pylint#4899 (comment), helped me reliably reproduce the issue. It seems that with pylint --extension-pkg-allow-list=pydantic, inference of dataclass from pydantic.dataclasses succeed (resulting in a FunctionDef) rather than yielding Uninferable, which is what #1144 handled.

Anyway, I added pydantic.dataclasses to an explicit allow-list for dataclass import modules, and this fixed the error. What I'm not sure about is (1) how/why --extension-pkg-allow-list affects this inference, and (2) how to update the tests for this, since I'd already added a bunch of tests for pydantic.dataclasses in my previous PR, but they already pass. Similarly, the pydantic.dataclasses test in pylint-dev/pylint#4919 already passes, but I'd be happy to add another Pylint test with --extension-pkg-allow-list=pydantic, with some guidance on setting config options and adding third-party modules for tests.

Feedback/ideas welcome!

(I also fixed one type annotation, that was an error from earlier.)

Type of Changes

Type
🐛 Bug fix

Related Issue

Closes pylint-dev/pylint#4899 (again).

@Pierre-Sassoulas
Copy link
Member

Hey, the issue with the CI is fixed in #1179, could you rebase on main when it's merged, please ?

@david-yz-liu
Copy link
Contributor Author

Just did, thanks!

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Clean fix !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instance of 'Field' has no 'append' member
2 participants