-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Correct function declaration for type hinting #6146
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
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
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.
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.
Pull Request Overview
This PR refactors the func attribute in the Subcommand class from a typed class attribute to a method stub with proper type annotations. This change provides better type safety and clarity for subcommand implementations.
- Changed
funcfrom aCallabletype annotation to a method stub with explicit parameter types - Removed unused
Callableimport from the typing module
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """ | ||
|
|
||
| func: Callable[[library.Library, optparse.Values, list[str]], Any] | ||
| def func(self, lib: library.Library, opts: optparse.Values, args: list[str]): ... |
Copilot
AI
Nov 5, 2025
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.
Converting func to an instance method will break all existing usage. Throughout the codebase, standalone functions without a self parameter are assigned to func (e.g., list_cmd.func = list_func where list_func(lib, opts, args) has no self). When called as subcommand.func(lib, suboptions, subargs) at line 1611, these functions won't receive the correct arguments. Consider using a protocol or keeping the original Callable type annotation to maintain compatibility with both attribute assignment and method overriding patterns.
| def func(self, lib: library.Library, opts: optparse.Values, args: list[str]): ... | |
| func: Callable[[library.Library, optparse.Values, list[str]], Any] |
| """ | ||
|
|
||
| func: Callable[[library.Library, optparse.Values, list[str]], Any] | ||
| def func(self, lib: library.Library, opts: optparse.Values, args: list[str]): ... |
Copilot
AI
Nov 5, 2025
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.
This statement has no effect.
| def func(self, lib: library.Library, opts: optparse.Values, args: list[str]): ... | |
| def func(self, lib: library.Library, opts: optparse.Values, args: list[str]): | |
| raise NotImplementedError("Subclasses must implement the func() method.") |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6146 +/- ##
==========================================
- Coverage 67.34% 67.33% -0.01%
==========================================
Files 136 136
Lines 18492 18492
Branches 3134 3135 +1
==========================================
- Hits 12453 12452 -1
Misses 5370 5370
- Partials 669 670 +1
🚀 New features to boost your workflow:
|
|
Thank you for the PR! Since this seems to be your first contribution to beets, you might want to have a quick look at our contribution guide and the developer documentation to get familiar with our workflow and coding conventions. This should help you fix the failing workflows. We're thrilled to have you contributing, welcome to the community! Can you extend your description a bit? Where and how did the warning/error occur? It is hard to follow the changes without a bit more information. |
Description
Fixes some type issues with
ruffcomplaining thatselfis not there.