Skip to content

Conversation

@JOJ0
Copy link
Member

@JOJ0 JOJ0 commented Dec 25, 2025

Description

Add type hints to the few remaining methods and helpers that didn't have them already.

To Do

  • Documentation.
  • Changelog.

@JOJ0 JOJ0 requested a review from a team as a code owner December 25, 2025 13:36
@github-actions
Copy link

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.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from 663b09d to d89a3cc Compare December 25, 2025 13:42
@JOJ0 JOJ0 force-pushed the lastgenre_type_hints_finalize branch from 39bfc3d to 59e1c53 Compare December 25, 2025 13:48
@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.22%. Comparing base (8dd6988) to head (b8c7c87).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/lastgenre/__init__.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6239   +/-   ##
=======================================
  Coverage   68.22%   68.22%           
=======================================
  Files         138      138           
  Lines       18791    18792    +1     
  Branches     3167     3167           
=======================================
+ Hits        12820    12821    +1     
  Misses       5298     5298           
  Partials      673      673           
Files with missing lines Coverage Δ
beetsplug/lastgenre/__init__.py 69.92% <94.44%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@semohr semohr left a comment

Choose a reason for hiding this comment

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

Seems like a no brainier to me! Thanks for the additions.

@snejus
Copy link
Member

snejus commented Dec 25, 2025

Thanks for this!

There are still a couple of missing types, would you mind adding them?

$ mypy beetsplug/lastgenre --strict --allow-untyped-call --pretty
beetsplug/lastgenre/__init__.py:96: error: Function is missing a return type annotation  [no-untyped-def]
        def __init__(self):
        ^
beetsplug/lastgenre/__init__.py:96: note: Use "-> None" if function does not return a value
beetsplug/lastgenre/__init__.py:168: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
        def _tunelog(self, msg, *args, **kwargs) -> None:
        ^
beetsplug/lastgenre/__init__.py:336: error: Returning Any from function declared to return "str"  [no-any-return]
            return self.config["separator"].as_str().join(formatted)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
beetsplug/lastgenre/__init__.py:379: error: Function is missing a return type annotation  [no-untyped-def]
            def _try_resolve_stage(stage_label: str, keep_genres, new_genres):
            ^
beetsplug/lastgenre/__init__.py:379: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
            def _try_resolve_stage(stage_label: str, keep_genres, new_genres):
            ^
beetsplug/lastgenre/__init__.py:416: error: Returning Any from function declared to return "tuple[str | None, ...]"  [no-any-return]
                        return result
                        ^~~~~~~~~~~~~
beetsplug/lastgenre/__init__.py:423: error: Returning Any from function declared to return "tuple[str | None, ...]"  [no-any-return]
                        return result
                        ^~~~~~~~~~~~~
beetsplug/lastgenre/__init__.py:474: error: Returning Any from function declared to return "tuple[str | None, ...]"  [no-any-return]
                        return result
                        ^~~~~~~~~~~~~
beetsplug/lastgenre/__init__.py:582: error: Function is missing a type annotation  [no-untyped-def]
            def lastgenre_func(lib, opts, args):
            ^
beetsplug/lastgenre/__init__.py:592: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
        def imported(self, session, task) -> None:
        ^
Found 10 errors in 1 file (checked 1 source file)

@JOJ0 JOJ0 force-pushed the lastgenre_type_hints_finalize branch from 59e1c53 to 6b465d8 Compare December 26, 2025 11:11
Copy link
Member Author

@JOJ0 JOJ0 left a comment

Choose a reason for hiding this comment

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

Thanks for this!

There are still a couple of missing types, would you mind adding them?

Many thanks for pointing that out @snejus . Added all of them and used that handy mypy command to check.

Do we usually add a changelog entry when we only add/finalize types in a plugin/code-part?

@snejus
Copy link
Member

snejus commented Dec 26, 2025

Thanks for this!
There are still a couple of missing types, would you mind adding them?

Many thanks for pointing that out @snejus . Added all of them and used that handy mypy command to check.

Do we usually add a changelog entry when we only add/finalize types in a plugin/code-part?

No need :)

@JOJ0 JOJ0 force-pushed the lastgenre_type_hints_finalize branch 2 times, most recently from d9d868f to 75ea776 Compare December 27, 2025 08:40
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from d89a3cc to 46bb0ac Compare December 29, 2025 22:44
@JOJ0 JOJ0 added this to the 2.6.0 milestone Dec 30, 2025
@JOJ0 JOJ0 force-pushed the lastgenre_multi_artist_fix branch from 46bb0ac to 28dc78b Compare December 30, 2025 19:57
Base automatically changed from lastgenre_multi_artist_fix to master December 30, 2025 20:03
Copilot AI review requested due to automatic review settings December 30, 2025 20:09
@JOJ0 JOJ0 force-pushed the lastgenre_type_hints_finalize branch from 75ea776 to 12d4263 Compare December 30, 2025 20:09
Copy link
Contributor

Copilot AI left a 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 completes the type hint coverage for the lastgenre plugin by adding type annotations to previously untyped methods and helper functions.

  • Adds type hints to utility functions (flatten_tree, find_parents)
  • Adds type hints to plugin lifecycle methods (__init__, setup, commands, imported)
  • Adds type hints to internal helper methods (_tunelog, _get_depth, _sort_by_depth, _try_resolve_stage, _tags_for)
  • Adds inline variable type annotations for better type clarity (_genre_cache, obj_to_query, res, tags)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JOJ0 JOJ0 force-pushed the lastgenre_type_hints_finalize branch 2 times, most recently from fdc6197 to 940d4df Compare December 30, 2025 20:32
to finally reach full type hint coverage in the plugin!
@JOJ0 JOJ0 force-pushed the lastgenre_type_hints_finalize branch from 940d4df to b8c7c87 Compare December 30, 2025 20:33
@JOJ0 JOJ0 merged commit e048909 into master Dec 30, 2025
21 checks passed
@JOJ0 JOJ0 deleted the lastgenre_type_hints_finalize branch December 30, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants