Skip to content

Conversation

@cdgaete
Copy link
Collaborator

@cdgaete cdgaete commented Apr 8, 2025

Changes proposed in this Pull Request

  • Add new .github/workflows/type-checking.yml workflow to run mypy static type checking on the codebase
  • Fix type errors in core.py by properly casting Path objects to strings (join function requires string paths)
  • Update dependencies in pyproject.toml:
    • Add mypy and required type stubs to dev dependencies (types-requests, types-PyYAML, pandas-stubs, types-tqdm, types-six)
    • Add a new 'plotting' dependency group for optional cartopy dependency
  • Add mypy configuration in pyproject.toml with appropriate settings for our code
  • Silence mypy "misc" errors in the accessor.py file
  • Configure external library import ignores for third-party packages

Additional improvements:

  • Update pre-commit config with end-of-file-fixer, trailing-whitespace and check-merge-conflict hooks
  • Fix cycler import in plot.py to avoid matplotlib deprecation warning
  • Fix various whitespace and end-of-file issues throughout the codebase (automated)

@euronion @FabianHofmann

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

@euronion
Copy link
Contributor

This looks very nice. Let us know when it is ready for review.

@cdgaete cdgaete marked this pull request as ready for review April 22, 2025 14:43
@euronion euronion requested a review from lkstrp April 22, 2025 14:47
@cdgaete
Copy link
Collaborator Author

cdgaete commented Apr 22, 2025

Hey @lkstrp, I'm submitting this PR focused on code quality improvements, which should help streamline our ongoing development work. There will be additional PRs coming in the next few weeks, but I wanted to prioritize this one first. As we discussed previously, I've postponed the doc-string enhancements for a later phase. Would appreciate your review when you have the opportunity!

@lkstrp
Copy link
Member

lkstrp commented Apr 22, 2025

That's perfect, thanks a lot @cgaete!
I just opened the other PR to get the pre commit diff out here. Will review and merge soon


makedirs(join(package_config["data_dir"], "data", "in"), exist_ok=True)
makedirs(join(package_config["data_dir"], "data", "out"), exist_ok=True)
makedirs(join(str(package_config["data_dir"]), "data", "in"), exist_ok=True)
Copy link
Member

Choose a reason for hiding this comment

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

No need to change for this PR, but just the note that we wanna move to pathlib in general. Not sure if mypy would be happy without the str cast then

@lkstrp lkstrp enabled auto-merge (squash) April 23, 2025 09:22
@lkstrp lkstrp merged commit 83e1a14 into PyPSA:master Apr 23, 2025
17 checks passed
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.

3 participants