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 typing module #27

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Remove typing module #27

merged 3 commits into from
Oct 23, 2024

Conversation

ChristianGeng
Copy link
Member

@ChristianGeng ChristianGeng commented Oct 23, 2024

Purpose

While removing support for Python 3.8 elseqhere, which has reached its end-of-life, typing is refactored. While audpsychometric does not support Python 3.8, it still uses the typing module for type hinting which is getting uncommon with more recent python versions e.g. list[str] for type hinting instead of typing.List[str]. I also removed occurrences of typing.Union in favor of using |. typing.Any is becoming object which is the highest type in Python's type hierarchy.

Copy link

sourcery-ai bot commented Oct 23, 2024

Reviewer's Guide by Sourcery

This pull request removes the typing module and updates type hints to use more modern Python syntax. The changes are primarily focused on improving type annotations and removing support for Python 3.8, which has reached its end-of-life.

Updated class diagram for type hinting changes

classDiagram
    class GoldStandard {
        +agreement_categorical(ratings: Sequence, axis: int) float | np.ndarray
        +agreement_numerical(ratings: Sequence, minimum: float, maximum: float, axis: int) float | np.ndarray
        +evaluator_weighted_estimator(ratings: Sequence, axis: int) float | np.ndarray
        +mode(ratings: Sequence, axis: int) object
        +rater_agreement(ratings: Sequence, axis: int) np.ndarray
        +_value_or_array(values: np.ndarray) float | np.ndarray
        +_mode(ratings: np.ndarray, remove_nan: bool) object
    }

    class Reliability {
        +cronbachs_alpha(ratings: Sequence, axis: int) tuple[float, dict]
        +congeneric_reliability(ratings: Sequence, axis: int) tuple[float, dict]
        +intra_class_correlation(ratings: Sequence, axis: int, icc_type: str, anova_method: str) tuple[float, dict]
    }

    class Datasets {
        +read_dataset(data_set_name: str) pd.DataFrame
        +list_datasets() pd.DataFrame
    }
Loading

File-Level Changes

Change Details Files
Replaced typing module imports with direct type annotations
  • Removed typing.Sequence in favor of Sequence
  • Replaced typing.Union[float, np.ndarray] with `float
np.ndarray</li><li>Changed typing.Anytoobject`
Updated function return type annotations
  • Changed typing.Union[float, np.ndarray] to `float
np.ndarray</li><li>Updated typing.Tuple[float, typing.Dict]totuple[float, dict]</li><li>Changed typing.Anytoobject`
Added return type annotation to list_datasets function
  • Added -> pd.DataFrame return type annotation
  • Updated function docstring to reflect the return type
audpsychometric/core/datasets/__init__.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 @ChristianGeng - 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.

@ChristianGeng ChristianGeng requested a review from hagenw October 23, 2024 05:31
@hagenw hagenw changed the title remove typing module. Remove typing module 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 for the updates looks all good to me. The change from typing.Any to object seems also reasonable to me. typing.Any was just telling a potential type checker to ignore it, whereas object is indeed the "highest" object in Python.

It also works in the documentation:

image

audpsychometric/core/datasets/__init__.py Outdated Show resolved Hide resolved
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.

All fine now.

@ChristianGeng ChristianGeng merged commit c136845 into main Oct 23, 2024
8 checks passed
@ChristianGeng ChristianGeng deleted the remove-typing-module branch October 23, 2024 11:32
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