Skip to content

Centralize add_segment and segments to BaseExtractor#4462

Open
alejoe91 wants to merge 21 commits intoSpikeInterface:mainfrom
alejoe91:segments
Open

Centralize add_segment and segments to BaseExtractor#4462
alejoe91 wants to merge 21 commits intoSpikeInterface:mainfrom
alejoe91:segments

Conversation

@alejoe91
Copy link
Member

and fix a bunch of typing errors

Pulled out of #4216

@alejoe91 alejoe91 added this to the 0.105.0 milestone Mar 23, 2026
@alejoe91 alejoe91 added the core Changes to core module label Mar 23, 2026
return len(self._segments)

def get_parent(self) -> BaseExtractor | None:
def get_parent(self) -> "BaseExtractor | None":
Copy link
Member

Choose a reason for hiding this comment

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

Hello. If you keep from __future__ import annotations you don't need to use string literals for self-referencing types. I think this is preferred, but might just be a style choice. At Python 3.11 we get a new type Self which is now the modern way to do self referencing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah nice! I would say we keep the string notation and get rid of future annotations. The main reason is that the __future__ import doesn't actually do any check, so we had a lot of bad typing (e.g., lists of | instead of Literal). This enforces us to be cleaner ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants