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

Update syntax to Python >=3.9 #463

Merged
merged 12 commits into from
Jan 17, 2025
Merged

Update syntax to Python >=3.9 #463

merged 12 commits into from
Jan 17, 2025

Conversation

hagenw
Copy link
Member

@hagenw hagenw commented Jan 17, 2025

Updates syntax to Python >=3.9 by removing the use of typing (with the exception of typing.Self in audformat/core/table.py type alias definitions in audformat/core/typing.py, and typing.TYPE_CHECKING in audformat/core/column.py).

Summary by Sourcery

Enhancements:

  • Use native Python 3.9 type hinting syntax instead of the typing library.

Copy link

sourcery-ai bot commented Jan 17, 2025

Reviewer's Guide by Sourcery

This pull request updates the code to use Python 3.9+ syntax, replacing typing hints with built-in types like list, dict, |, etc. This change improves code readability and leverages modern Python features.

Class diagram showing updated type hints in Table class

classDiagram
    class Table {
        +media() Media|None
        +split() Split|None
        +drop_columns(column_ids: str|Sequence[str], inplace: bool) Self
        +extend_index(index: Index, fill_values: object|dict[str, object]) Self
        +get(index: Index, map: dict[str, str|Sequence[str]]) DataFrame
        +pick_columns(column_ids: str|Sequence[str]) Self
        +set(values: dict[str, Values]|DataFrame)
        +update(others: Self|Sequence[Self]) Self
        -_levels_and_dtypes() dict[str, str]
    }
    note for Table "Updated type hints to use Python 3.9+ syntax with | operator"
Loading

Class diagram showing updated type hints in Column class

classDiagram
    class Column {
        +rater() Rater|None
        +scheme() Scheme|None
        +get(as_segmented: bool, allow_nat: bool, num_workers: int|None) Series
        +__eq__(other: Column) bool
    }
    note for Column "Updated type hints to use Python 3.9+ syntax with | operator"
Loading

Class diagram showing updated type hints in Scheme class

classDiagram
    class Scheme {
        +is_numeric() bool
        +labels_as_list() list
        -_labels_to_dict(labels: dict|list|str) dict
        -_labels_to_list(labels: dict|list|str) list
    }
    note for Scheme "Updated type hints to use built-in list and dict types"
Loading

File-Level Changes

Change Details Files
Replaced typing.Optional[X] with `X None`.
  • Updated type hints for optional attributes and function return values.
Replaced typing.Union[X, Y] with `X Y`.
  • Updated type hints for functions accepting multiple types.
Replaced typing.Sequence with Sequence.
  • Updated type hints for sequence types.
audformat/core/table.py
audformat/core/testing.py
Replaced typing.Dict with dict.
  • Updated type hints for dictionary types.
audformat/core/table.py
audformat/core/testing.py
audformat/core/utils.py
audformat/core/scheme.py
Replaced typing.List with list.
  • Updated type hints for list types.
audformat/core/utils.py
audformat/core/scheme.py
audformat/core/attachment.py
audformat/core/common.py
Removed unnecessary typing.Any and replaced with object.
  • Updated type hints for generic object types.
audformat/core/table.py
Replaced typing.Callable with Callable.
  • Updated type hints for callable types.
audformat/core/table.py
audformat/core/testing.py
audformat/core/utils.py
Replaced typing.Tuple with tuple.
  • Updated type hints for tuple types.
audformat/core/utils.py
audformat/core/testing.py
Replaced typing.Self with typing.Self.
  • Retained typing.Self for methods that return an instance of the class.
audformat/core/table.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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

@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 and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 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.

tests/test_database.py Show resolved Hide resolved
tests/test_database.py Show resolved Hide resolved
audformat/core/utils.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.0%. Comparing base (8bbff3e) to head (f86ba00).
Report is 1 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
audformat/core/attachment.py 100.0% <ø> (ø)
audformat/core/column.py 100.0% <100.0%> (ø)
audformat/core/common.py 100.0% <100.0%> (ø)
audformat/core/database.py 100.0% <100.0%> (ø)
audformat/core/errors.py 100.0% <100.0%> (ø)
audformat/core/index.py 100.0% <100.0%> (ø)
audformat/core/media.py 100.0% <100.0%> (ø)
audformat/core/scheme.py 100.0% <100.0%> (ø)
audformat/core/table.py 100.0% <100.0%> (ø)
audformat/core/testing.py 100.0% <100.0%> (ø)
... and 2 more

@hagenw hagenw merged commit 501b699 into main Jan 17, 2025
12 checks passed
@hagenw hagenw deleted the update-syntax branch January 17, 2025 18:16
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