Skip to content

Update syntax to Python >=3.9#194

Merged
hagenw merged 4 commits intomainfrom
update-syntax
Jun 5, 2025
Merged

Update syntax to Python >=3.9#194
hagenw merged 4 commits intomainfrom
update-syntax

Conversation

@hagenw
Copy link
Copy Markdown
Member

@hagenw hagenw commented Jun 5, 2025

Updates syntax to Python >=3.9 by removing the use of typing.

Summary by Sourcery

Update type hints across core modules to use Python 3.9+ syntax, replacing typing module constructs with PEP 585 generics and the native union operator.

Enhancements:

  • Adopt PEP 585 built-in generics by replacing typing.Dict, typing.List, typing.Tuple, and typing.Callable with dict, list, tuple, and Callable annotations
  • Replace typing.Union and typing.Optional with the native | union operator and import Sequence from collections.abc
  • Add future.annotations and remove redundant typing imports to streamline type hints for Python >=3.9

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 5, 2025

Reviewer's Guide

Refactor all type annotations to Python 3.9+ syntax by replacing typing.* generics and unions with built-in generics, PEP 585 collections, and PEP 604 union operators, and adjust imports for future annotations support.

File-Level Changes

Change Details Files
Migrate type hints to built-in generics and PEP 604 unions
  • Replace typing.Dict[X, Y] with dict[X, Y]
  • Replace typing.List[T] and Sequence[T] with list[T] and Sequence[T]
  • Replace typing.Tuple[…] with tuple[…]
  • Replace typing.Union[T1, T2] and Optional[T] with T1
T2 and T
Simplify return and callable annotations
  • Change returns from typing.Any to object
  • Change Callable[..., typing.Any] and Callable[..., Sequence[Any]] to Callable[..., object] and Callable[..., Sequence[object]]
audinterface/core/process.py
audinterface/core/process_with_context.py
audinterface/core/segment_with_feature.py
audinterface/core/feature.py
audinterface/core/segment.py
Enable postponed evaluation and adjust imports
  • Add from __future__ import annotations in typing module
  • Import Sequence from collections.abc instead of typing
  • Remove direct typing import usages
audinterface/core/typing.py
audinterface/core/utils.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
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 @hagenw - I've reviewed your changes - here's some feedback:

  • Replacing typing.Any with object changes the type‐checker semantics—object is more restrictive than Any, so double-check that this change is intentional.
  • Ensure all new annotation names (Callable, Sequence, etc.) are imported from the correct modules (e.g. collections.abc) since typing imports were removed.
  • Confirm that using built-in generics like list[str] and dict[str, object] aligns with your minimum Python and tooling versions so no unexpected compatibility issues arise.
Here's what I looked at during the review
  • 🟡 General issues: 5 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

Comment thread audinterface/core/process.py Outdated
Comment thread audinterface/core/process.py Outdated
Comment thread audinterface/core/process.py
Comment thread audinterface/core/segment_with_feature.py Outdated
Comment thread audinterface/core/process_with_context.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.0%. Comparing base (3723bc3) to head (5c7d6fa).
Report is 2 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
audinterface/core/feature.py 100.0% <100.0%> (ø)
audinterface/core/process.py 100.0% <100.0%> (ø)
audinterface/core/process_with_context.py 100.0% <100.0%> (ø)
audinterface/core/segment.py 100.0% <100.0%> (ø)
audinterface/core/segment_with_feature.py 100.0% <100.0%> (ø)
audinterface/core/typing.py 100.0% <100.0%> (ø)
audinterface/core/utils.py 100.0% <100.0%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hagenw hagenw merged commit 812a5dc into main Jun 5, 2025
19 checks passed
@hagenw hagenw deleted the update-syntax branch June 5, 2025 14: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.

1 participant