Uh oh!
There was an error while loading. Please reload this page.
Fix generic inheritance for dataclass init methods - #9380
Conversation
One of the test jobs failed (python3.5.1 with mypyc). The errors appear unrelated to my changes, and that same job passed when I ran the same commit hash - https://travis-ci.org/github/natemcmaster/mypy/builds/722519864. Is this failure due to flaky tests? |
JelleZijlstra
commented
Sep 1, 2020
@natemcmaster it's likely due to a recent setuptools release that broke stuff; I submitted a PR that will hopefully fix CI. |
natemcmaster
commented
Sep 3, 2020
@JelleZijlstra thanks! I merged latest updates from master into my PR. CI is passing now on this PR. |
natemcmaster
commented
Sep 30, 2020
Friendly bump for review :) |
natemcmaster
commented
Nov 13, 2020
Hello there, checking in again. I merged from master and pushed to my branch to ensure this PR is still merge-conflict free and passing tests. Any chance I can get a review? Thanks! |
Any status on the review? I have a super lame generic dataclass inheritance chain mess that's waiting on it. And I'm sure you don't have anything better to do... |
natemcmaster
commented
Nov 20, 2020
I haven't heard anything from the repo maintainers :-/ |
hauntsaninja
commented
Nov 28, 2020
Thanks for this (and #9383)! Sorry for the delay here, mypy's just been really short on reviewer bandwidth / I've shied away from reviewing these because I'm not familiar with these plugins. But the change make sense, your tests look good and mypy_primer doesn't surface any complaints. |
natemcmaster
commented
Nov 28, 2020
Thanks for merging this and the other PR, @hauntsaninja! I totally understand the delay. I used to be a maintainer on a big open source project myself :). Thanks for following up on this! |
binishkaspar
commented
Dec 18, 2020
@natemcmaster Fix works very well. However the following code raises INTERNAL ERROR, DRIVE_TYPE=TypeVar('DRIVE_TYPE', bound='Driver')
# This WORKS# DRIVER_STATE_TYPE = TypeVar('DRIVER_STATE_TYPE', bound='DriverState')@dataclassclassDriverState(Generic[DRIVE_TYPE]):
driver: DRIVE_TYPEpid: str=''# This doesn't workDRIVER_STATE_TYPE=TypeVar('DRIVER_STATE_TYPE', bound='DriverState')
@dataclassclassDriver(Generic[DRIVER_STATE_TYPE]):
config: DRIVER_STATE_TYPE@dataclassclassESState(DriverState['ESDriver']):
special_name: str='ES Driver'@dataclassclassESDriver(Driver[
ESState
]):
defname(self) ->None:
print(self.config.special_name)Is it because |
natemcmaster
commented
Dec 21, 2020
@binishkaspar can you open a new issue? I'm not sure of the expected behavior of TypeVar with an open generic bound. |
Description
Fixes#7520
Updates the dataclasses plugin. Instead of directly copying attribute type along the MRO, this first resolves typevar in the context of the subtype.
Test Plan
Added 4 new test cases to cover various generic inheritance scenarios.