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

fix mypy and ruff errors #257

Merged
merged 12 commits into from
Jun 14, 2024
Merged

fix mypy and ruff errors #257

merged 12 commits into from
Jun 14, 2024

Conversation

CunliangGeng
Copy link
Member

@CunliangGeng CunliangGeng commented Jun 11, 2024

This PR tries to solve all type hints errors (mypy), formatting errors (ruff) and typos for refactored code. As for non-refactored code, we keep it as it is.

As for type hints, the changes follow the rules below:

  • use @overload for different data types of the same argument
  • use broader type hints Sequence and Mapping to replace list and dict, respectively, as much as possible
  • Use TYPE_CHECKING to only avoid circular imports

@CunliangGeng CunliangGeng marked this pull request as ready for review June 11, 2024 07:37
@CunliangGeng CunliangGeng self-assigned this Jun 11, 2024
@CunliangGeng
Copy link
Member Author

It's ready for review.

Copy link
Contributor

@gcroci2 gcroci2 left a comment

Choose a reason for hiding this comment

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

In general, there are many lines touched by this PR where Mapping or Sequence are not used for type hints instead of dict and list. I started commenting on them, but since I realized they are quite a lot I wonder if there is a reason for this. Before I keep leaving many comments, better to know ;)

src/nplinker/genomics/abc.py Outdated Show resolved Hide resolved
src/nplinker/metabolomics/abc.py Outdated Show resolved Hide resolved
src/nplinker/metabolomics/abc.py Outdated Show resolved Hide resolved
src/nplinker/metabolomics/abc.py Outdated Show resolved Hide resolved
Copy link
Member Author

CunliangGeng commented Jun 14, 2024

Merge activity

  • Jun 14, 7:27 AM EDT: @CunliangGeng started a stack merge that includes this pull request via Graphite.
  • Jun 14, 7:36 AM EDT: Graphite rebased this pull request as part of a merge.
  • Jun 14, 7:38 AM EDT: @CunliangGeng merged this pull request with Graphite.

Base automatically changed from refactor_NPLinker_methods to dev June 14, 2024 11:34
This ensures that the type hints are available both during type checking and at runtime, improving code clarity and reducing the chance of runtime errors related to type hints.
use broader type hints Sequence and Mapping to replace list and dict, respectively
@CunliangGeng CunliangGeng merged commit 6a6f170 into dev Jun 14, 2024
2 of 3 checks passed
@CunliangGeng CunliangGeng deleted the fix_mypy_ruff_errors branch June 14, 2024 11:38
Copy link

sonarcloud bot commented Jun 14, 2024

This was referenced Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants