Skip to content

Use abc.ABC as baseclass for AnyPath to fix issubclass behavior#251

Merged
pjbull merged 2 commits into
drivendataorg:251-live-testsfrom
chbehrens:anypath-subclasses-via-abc
Aug 18, 2022
Merged

Use abc.ABC as baseclass for AnyPath to fix issubclass behavior#251
pjbull merged 2 commits into
drivendataorg:251-live-testsfrom
chbehrens:anypath-subclasses-via-abc

Conversation

@chbehrens

Copy link
Copy Markdown
Contributor

Following @jayqi's suggestion in #247, this PR lets AnyPath inherit from abc.ABC and sets its subclasses via ABC.register. It also adds a test to check the bug filed in #246.

Fixes #246

@chbehrens
chbehrens force-pushed the anypath-subclasses-via-abc branch from cda41c5 to b9036df Compare August 17, 2022 11:53
@pjbull

pjbull commented Aug 17, 2022

Copy link
Copy Markdown
Member

Hm @chbehrens, looks like mypy and ABC have some rough edges. See python/mypy#2922, python/mypy#5374, https://stackoverflow.com/questions/69330256/how-to-get-an-abstract-dataclass-to-pass-mypy

Ironically, it looks like the metaclass implementation might pass mypy (see python/mypy#1459 (comment))

I'm ok with a # type: ignore on the line that is erroring. That work for you @jayqi?

@jayqi

jayqi commented Aug 17, 2022

Copy link
Copy Markdown
Member

I'm also fine with a # type: ignore.

I was also looking at python/mypy#5374 and it seems like it's possible this is addressed very recently in mypy (just 5 days ago) by python/mypy#13398. That PR was merged but is not released yet, so I think we'll potentially look at revisiting once the next release of mypy is published.

@chbehrens

Copy link
Copy Markdown
Contributor Author

Ok, I added the # type: ignore and will try to keep it in mind.

@pjbull

pjbull commented Aug 18, 2022

Copy link
Copy Markdown
Member

Thanks @chbehrens! You can ignore the failure for now, Github Actions is having an outage:
https://www.githubstatus.com/

I'll rerun these later once they stabilize the service

@pjbull

pjbull commented Aug 18, 2022

Copy link
Copy Markdown
Member

Changes look good, thanks @chbehrens! I'm going to move this to a local branch to run the live server tests.

@pjbull
pjbull changed the base branch from master to 251-live-tests August 18, 2022 18:07
@pjbull
pjbull merged commit b5cdc3f into drivendataorg:251-live-tests Aug 18, 2022
pjbull added a commit that referenced this pull request Aug 18, 2022
#257)

* Use abc.ABC as baseclass for AnyPath

* add type ignore for ABC.register

Co-authored-by: chbehrens <chbehrens@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AnyPath is not a subclass of AnyPath

3 participants