-
Notifications
You must be signed in to change notification settings - Fork 27
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 Compliance #1300
base: main
Are you sure you want to change the base?
MyPy Compliance #1300
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1300 +/- ##
==========================================
- Coverage 91.64% 91.56% -0.08%
==========================================
Files 59 59
Lines 2991 3012 +21
==========================================
+ Hits 2741 2758 +17
- Misses 250 254 +4 ☔ View full report in Codecov by Sentry. |
@@ -717,10 +719,10 @@ def from_points( | |||
@classmethod | |||
def from_tiff( | |||
cls, | |||
fname: PathLike, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently PathLike
doesn't guarantee the .resolve
method.
name: str | None = None, | ||
band: int | None = 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MyPy couldn't cope with this potentially being None
, and as far as I could tell it would be impossible for it to be None
anyway since it has a default?
Frankly I would have liked to do the same for rgb
as well but this triggers Ruff FBT001
, which seems fair enough.
if isinstance(fname, str): | ||
fname = Path(fname) | ||
|
||
fname = fname.resolve(strict=True) | ||
band = None if rgb else band |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MyPy behaved better with consistent types, and as far as I can see None
and -1
are irrelevant anyway given the way rgb
is handled.
@@ -1154,8 +1162,7 @@ def from_unstructured( | |||
if not name: | |||
size = data.size // data.shape[-1] if rgb else data.size | |||
name = NAME_POINTS if size == mesh.n_points else NAME_CELLS | |||
if not isinstance(name, str): | |||
name = str(name) | |||
assert isinstance(name, str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this ever be any other type? If so what?
|
||
|
||
def sanitize_data( | ||
*meshes: Iterable[pv.PolyData], | ||
*meshes: pv.PolyData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked this up - the Iterable
is implicit with *
parameters, which explains why MyPy was unhappy here.
@@ -701,7 +705,7 @@ def _check(option: str) -> bool: | |||
# POI cartesian xyz | |||
self._poi = mesh.center | |||
|
|||
return super().add_mesh(mesh, **kwargs) | |||
return super().add_mesh(mesh, **kwargs) # type: ignore[misc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to give GeoPlotterBase
various methods using Callable
type hints - since we know the intended use in multiple inheritance with a PyVista plotter - but I couldn't see an elegant way of doing anything analogous with references to super()
, hence the ignore
.
🚀 Pull Request
Description
See project item