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

Remove support for Python 3.8 #60

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Remove support for Python 3.8 #60

merged 3 commits into from
Oct 23, 2024

Conversation

ChristianGeng
Copy link
Member

@ChristianGeng ChristianGeng commented Oct 23, 2024

Summary by Sourcery

Update type hinting to use PEP 585 style and remove Python 3.8 from CI configuration.

Enhancements:

  • Replace typing module imports with PEP 585 type hinting style using built-in generic types.

CI:

  • Remove Python 3.8 from the CI testing matrix.

Copy link

sourcery-ai bot commented Oct 23, 2024

Reviewer's Guide by Sourcery

This pull request updates the project to remove Python 3.8 support and modernize type annotations. The changes primarily involve updating type hints in the audmetric/core/api.py and audmetric/core/utils.py files, as well as removing Python 3.8 from the GitHub Actions test workflow.

Architecture diagram for GitHub Actions workflow update

graph TD;
    A[GitHub Actions Workflow] -->|Removed| B[Python 3.8 Test Job];
    A --> C[Python 3.9 Test Job];
    A --> D[Python 3.10 Test Job];
    A --> E[OS: Ubuntu, macOS, Windows];
Loading

Updated class diagram for type annotations in audmetric/core/api.py

classDiagram
    class API {
        +accuracy(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[str | int] = None) float
        +concordance_cc(truth: Sequence[float], prediction: Sequence[float]) float
        +confusion_matrix(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[object] = None) list[list[int | float]]
        +detection_error_tradeoff(truth: Sequence[bool | int], prediction: Sequence[bool | int | float]) tuple[np.ndarray, np.ndarray, np.ndarray]
        +edit_distance(truth: str | Sequence[int], prediction: str | Sequence[int]) int
        +equal_error_rate(truth: Sequence[bool | int], prediction: Sequence[bool | int | float]) tuple[float, collections.namedtuple]
        +event_error_rate(truth: str | Sequence[str | Sequence[int]], prediction: str | Sequence[str | Sequence[int]]) float
        +fscore_per_class(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[object] = None, zero_division: float = 0) dict[str, float]
        +linkability(truth: bool | int | Sequence[bool | int], prediction: bool | int | float | Sequence[bool | int | float], omega: float = 1.0, nbins: int = None) float
        +mean_absolute_error(truth: Sequence[float], prediction: Sequence[float]) float
        +mean_squared_error(truth: Sequence[float], prediction: Sequence[float]) float
        +pearson_cc(truth: Sequence[float], prediction: Sequence[float]) float
        +precision_per_class(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[object] = None, zero_division: float = 0) dict[str, float]
        +recall_per_class(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[object] = None, zero_division: float = 0) dict[str, float]
        +unweighted_average_bias(truth: Sequence[object], prediction: Sequence[object], protected_variable: Sequence[object], labels: Sequence[object] = None, subgroups: Sequence[object] = None, metric: Callable[[Sequence[object], Sequence[object], Sequence[str] | None], dict[str, float]] = fscore_per_class, reduction: Callable[[Sequence[float]], float] = np.std) float
        +unweighted_average_fscore(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[object] = None, zero_division: float = 0) float
        +unweighted_average_precision(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[object] = None, zero_division: float = 0) float
        +unweighted_average_recall(truth: Sequence[object], prediction: Sequence[object], labels: Sequence[object] = None, zero_division: float = 0) float
        +weighted_confusion_error(truth: Sequence[object], prediction: Sequence[object], weights: Sequence[Sequence[int | float]], labels: Sequence[object] = None) float
        +word_error_rate(truth: Sequence[Sequence[str]], prediction: Sequence[Sequence[str]]) float
        +_matching_scores(truth: bool | int | Sequence[bool | int], prediction: bool | int | float | Sequence[bool | int | float]) tuple[np.ndarray, np.ndarray]
    }
Loading

Updated class diagram for type annotations in audmetric/core/utils.py

classDiagram
    class Utils {
        +assert_equal_length(truth: Sequence[object], prediction: Sequence[object])
        +infer_labels(truth: Sequence[object], prediction: Sequence[object]) list[object]
        +scores_per_subgroup_and_class(truth: Sequence[object], prediction: Sequence[object], protected_variable: Sequence[object], metric: Callable[[Sequence[object], Sequence[object], Sequence[str] | None, float], dict[str, float]], labels: Sequence[object], subgroups: Sequence[object], zero_division: float) dict[Hashable, dict]
    }
Loading

File-Level Changes

Change Details Files
Update type annotations to use more modern syntax
  • Replace typing.Sequence with Sequence
  • Use `
for union types instead oftyping.Union</li><li>Update return type annotations to use listanddictinstead oftyping.Listandtyping.Dict</li><li>Use objectinstead oftyping.Any` for more general type hints
  • Update callable type hints to use more specific parameter and return types
  • Remove Python 3.8 support from CI workflow
    • Remove the job matrix entry for Python 3.8 on Ubuntu
    .github/workflows/test.yml
    Minor code improvements
    • Add from __future__ import annotations to enable postponed evaluation of annotations
    • Replace set([...]) with set literal {...}
    • Import specific types from collections.abc instead of using typing
    audmetric/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.
    • 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

    codecov bot commented Oct 23, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 100.0%. Comparing base (5fb7e2f) to head (9c3453a).
    Report is 1 commits behind head on main.

    Additional details and impacted files
    Files with missing lines Coverage Δ
    audmetric/core/api.py 100.0% <100.0%> (ø)
    audmetric/core/utils.py 100.0% <100.0%> (ø)

    @ChristianGeng ChristianGeng marked this pull request as ready for review October 23, 2024 11:36
    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 @ChristianGeng - I've reviewed your changes and they look great!

    Here's what I looked at during the review
    • 🟡 General issues: 1 issue 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.

    audmetric/core/api.py Show resolved Hide resolved
    @hagenw hagenw changed the title Purge 3.8 from project files. Purge 3.8 from project files Oct 23, 2024
    Copy link
    Member

    @hagenw hagenw left a comment

    Choose a reason for hiding this comment

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

    Thanks, looks all good.

    I would prefer to rename the pull request to "Remove support for Python 3.8" to be in line with the naming we did so far when removing a Python version.

    audmetric/core/api.py Show resolved Hide resolved
    @ChristianGeng ChristianGeng changed the title Purge 3.8 from project files Remove support for Python 3.8 Oct 23, 2024
    @ChristianGeng
    Copy link
    Member Author

    Thanks, looks all good.

    I would prefer to rename the pull request to "Remove support for Python 3.8" to be in line with the naming we did so far when removing a Python version.

    Oh. This was suggested by github. I did not expect it to name it after a commit.

    @ChristianGeng ChristianGeng merged commit 49f0e4c into main Oct 23, 2024
    10 checks passed
    @ChristianGeng ChristianGeng deleted the remove-python-3.8 branch October 23, 2024 13:22
    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.

    2 participants