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

Improve typing references for events #1040

Closed
fmigneault opened this issue Jun 19, 2024 · 0 comments · Fixed by #1058
Closed

Improve typing references for events #1040

fmigneault opened this issue Jun 19, 2024 · 0 comments · Fixed by #1058
Labels

Comments

@fmigneault
Copy link

The library defines multiple types such as FileSystemMovedEvent, DirMovedEvent, etc., but does not employ them for on_moved event handler. Instead, it uses the generic FileSystemEvent, which somewhat defeats the purpose of having the event-specific types.

When defining a derived event handler class using the explicit types as below, mypy will complain that it "violates the Liskov substitution principle" as described in https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides, which also makes the definition of handler with the specific types provided inadequate.

def on_moved(self, event: FileSystemMovedEvent | DirMovedEvent): ...

Would it be possible to adjust the types to the specific events expected by each method? The current workaround is to type: ignore, also defining the purpose of defining the types in the first place.

BoboTiG added a commit to BoboTiG/watchdog that referenced this issue Aug 11, 2024
BoboTiG added a commit to BoboTiG/watchdog that referenced this issue Aug 11, 2024
@BoboTiG BoboTiG added the core label Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants