Replies: 1 comment
-
I'm fairly satisfied with this solution I came up with: from typing import TYPE_CHECKING
if TYPE_CHECKING:
class PreprocessedArray(xr.DataArray):
"""A DataArray which has gone through preprocessing"""
else:
PreprocessedArray = xr.DataArray |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wrote some code that looks roughly like:
Note that PreprocessedArray is never instantiated or used at runtime. This is purely for type checking so that I will be alerted by my IDE's type checker in case I try to run
process
on an array which hasn't yet been preprocessed.Unfortunately I get the warning
This isn't so big of a deal, and I can just add the line
to my class definition, but it feels really out-of-place. Am I doing this right? I saw a bunch of discussion at #3980, and I was wondering if this use case has been considered. (Making a subclass which is never used.)
Beta Was this translation helpful? Give feedback.
All reactions