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 Pathlib usage and docstrings #68

Merged
merged 6 commits into from
Apr 11, 2024
Merged

Update Pathlib usage and docstrings #68

merged 6 commits into from
Apr 11, 2024

Conversation

willGraham01
Copy link
Contributor

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

Standardises our imports of pathlib Paths and avoids importing the whole module when we only need the Path class.

What does this PR do?

  • Standardises our import of Path to from pathlib import Path across the package.
  • Updates / adds docstrings to a few functions that reply on Path inputs.

References

No issues, but picked up on in a comment on #65 (comment)

How has this PR been tested?

Tests pass locally. No package functionality should be changed, either.

Is this a breaking change?

No.

Does this PR require an update to the documentation?

N/A

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.54%. Comparing base (3b632c2) to head (27cdba4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
- Coverage   90.56%   90.54%   -0.02%     
==========================================
  Files          35       35              
  Lines        1356     1364       +8     
==========================================
+ Hits         1228     1235       +7     
- Misses        128      129       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@willGraham01 willGraham01 requested a review from K-Meech April 10, 2024 11:18
@willGraham01
Copy link
Contributor Author

CodeCov doesn't like my TYPE_CHECKING imports in files where we don't actually need to instantiate a Path object.

Happy to change those to regular imports on reviewer's request to avoid the red-cross-of-doom 😅

@willGraham01 willGraham01 requested a review from a team April 10, 2024 11:19
Copy link
Contributor

@K-Meech K-Meech left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just a few minor changes I noted in the comments. For the TYPE_CHECKING imports I wonder if there's a way to exclude these lines from codecov as coverage can do? Otherwise, probably best to just use standard imports to avoid the red cross 😅

brainglobe_utils/IO/cells.py Outdated Show resolved Hide resolved
brainglobe_utils/IO/cells.py Outdated Show resolved Hide resolved
brainglobe_utils/IO/cells.py Outdated Show resolved Hide resolved
brainglobe_utils/IO/cells.py Outdated Show resolved Hide resolved
brainglobe_utils/IO/yaml.py Outdated Show resolved Hide resolved
brainglobe_utils/general/pathlib.py Outdated Show resolved Hide resolved
@willGraham01
Copy link
Contributor Author

For the TYPE_CHECKING imports I wonder if there's a way to exclude these lines from codecov nedbat/coveragepy#831 (comment)?

Went for the straight-up import solution 😅 The solution given in the linked issue seems to imply that the .coveragerc file should be on a per-repo basis, and I don't want to escalate this PR to setting a precedent for the whole project. The #pragma: no cov solution is also ugly to include in each of the blocks (and could very easily get misplaced after a few edits if imports are moved around / changed).

@willGraham01 willGraham01 requested a review from K-Meech April 10, 2024 13:43
Copy link
Contributor

@K-Meech K-Meech left a comment

Choose a reason for hiding this comment

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

Looks good! For consistency, I just highlighted a few areas where quotes are no longer needed around the types.

brainglobe_utils/IO/surfaces.py Outdated Show resolved Hide resolved
brainglobe_utils/IO/yaml.py Outdated Show resolved Hide resolved
brainglobe_utils/general/pathlib.py Outdated Show resolved Hide resolved
brainglobe_utils/general/string.py Outdated Show resolved Hide resolved
brainglobe_utils/IO/yaml.py Outdated Show resolved Hide resolved
brainglobe_utils/IO/yaml.py Outdated Show resolved Hide resolved
All the "Path"s

Co-authored-by: Kimberly Meechan <[email protected]>
@willGraham01
Copy link
Contributor Author

where quotes are no longer needed around the types

VSCode linter why have you forsaken me 😭

@willGraham01 willGraham01 requested a review from K-Meech April 11, 2024 08:09
Copy link
Contributor

@K-Meech K-Meech left a comment

Choose a reason for hiding this comment

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

Looks good! I'll go ahead and merge now.

@K-Meech K-Meech merged commit 6b91e15 into main Apr 11, 2024
12 checks passed
@K-Meech K-Meech deleted the wgraham-pathlib branch April 11, 2024 08:51
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