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

mypy error Class cannot subclass "Task" (has type "Any") #14

Open
philvarner opened this issue Mar 8, 2023 · 2 comments
Open

mypy error Class cannot subclass "Task" (has type "Any") #14

philvarner opened this issue Mar 8, 2023 · 2 comments

Comments

@philvarner
Copy link

I have code like:

class MyDatasetToStac(Task): 

That returns this error from mypy:

task.py:30: error: Class cannot subclass "Task" (has type "Any")  [misc]

The fix is to add:

class Sentinel2ToStac(Task): # type: ignore

However, it would be nice if stactask provided the correct type information so that this was not necessary.

Description of this general issue is here: https://stackoverflow.com/questions/49888155/class-cannot-subclass-qobject-has-type-any-using-mypy

@matthewhanson
Copy link
Member

I reviewed the issue but it's not clear how to provide type information for the class.

@philvarner
Copy link
Author

I wasn't able to figure out why this isn't working. The class seems to be fully-annotated and there's an empty py.typed file in the root, so typechecking should work. All of the examples I found of this not working didn't apply to our case.

This errors because of disallow-subclassing-any, and for some reason, classes extending Task think it has type Any.

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

No branches or pull requests

2 participants