Skip to content

Conversation

@jl-wynen
Copy link
Member

Same procedure as every time

Comment on lines 190 to -203
exclude = [
'scipp/__init__\.py',
'scipp/coords/',
'scipp/curve_fit\.py',
'scipp/format/formatter\.py',
'scipp/io/hdf5\.py',
'scipp/logging\.py',
'scipp/object_list\.py',
'scipp/operations\.py',
'scipp/reduction\.py',
'scipp/scipy/integrate/__init__\.py',
'scipp/scipy/optimize/__init__\.py',
'scipp/testing/strategies\.py',
'scipp/utils/profile\.py',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, list is getting very short!

Comment on lines -22 to -31
from typing import Protocol as _Protocol

# Importing CoordTable from coord_table.py would result in an import
# cycle because that module imports rule.py
# CoordTable is only needed for type annotations here,
# so a protocol is enough.
class _CoordProvider(_Protocol):
def consume(self, name: str) -> Coord:
pass

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the comment wrong, or what has changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't wrong. But the new solution matches what we do in other places (

if TYPE_CHECKING:
from coord_table import CoordTable
else:
CoordTable = Any
) Import cycles are fine when type checking. And during runtime, we don't need to provide a precise type hint because we don't use any runtime type checker.

@jl-wynen jl-wynen enabled auto-merge January 30, 2025 11:57
@jl-wynen jl-wynen merged commit 015f4f5 into main Jan 30, 2025
4 checks passed
@jl-wynen jl-wynen deleted the appease-mypy branch January 30, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants