Support dataclass inference for pydantic.dataclasses. #1178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Steps
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 ofdataclass
frompydantic.dataclasses
succeed (resulting in aFunctionDef
) rather than yieldingUninferable
, 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 forpydantic.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
Related Issue
Closes pylint-dev/pylint#4899 (again).