-
Notifications
You must be signed in to change notification settings - Fork 18
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
Adds type hints throughout Hatchet and integrate checks with mypy #153
Open
ilumsden
wants to merge
5
commits into
LLNL:develop
Choose a base branch
from
TauferLab:static_typing_mypy
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ilumsden
added
area-ci
Issues and PRs related to continuous integration processes used by Hatchet developers
area-external
Issues and PRs related to external libraries used by Hatchet
area-graphframe
Issues and PRs involving Hatchet's core GraphFrame datastructure and associated classes
area-query-lang
Issues and PRs related to Hatchet's query language
area-readers
Issues and PRs involving Hatchet's data readers
area-utils
Issues and PRs related to Hatchets high-level API and other utility libraries
area-writers
Issues and PRs involving Hatchet's data writers
priority-normal
Normal priority issues and PRs
status-work-in-progress
PR is currently being worked on
type-internal-cleanup
PR or issues related to the structure of the codebase, directories and refactors
labels
Nov 14, 2024
Also, as a small add-on to this PR, I've updated the |
ilumsden
force-pushed
the
static_typing_mypy
branch
from
November 14, 2024 21:32
4f0e58f
to
6dd311d
Compare
ilumsden
added
status-ready-for-review
This PR is ready to be reviewed by assigned reviewers
and removed
status-work-in-progress
PR is currently being worked on
labels
Nov 14, 2024
ilumsden
force-pushed
the
static_typing_mypy
branch
from
November 14, 2024 21:39
6dd311d
to
9e44373
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-ci
Issues and PRs related to continuous integration processes used by Hatchet developers
area-external
Issues and PRs related to external libraries used by Hatchet
area-graphframe
Issues and PRs involving Hatchet's core GraphFrame datastructure and associated classes
area-query-lang
Issues and PRs related to Hatchet's query language
area-readers
Issues and PRs involving Hatchet's data readers
area-utils
Issues and PRs related to Hatchets high-level API and other utility libraries
area-writers
Issues and PRs involving Hatchet's data writers
priority-normal
Normal priority issues and PRs
status-ready-for-review
This PR is ready to be reviewed by assigned reviewers
type-internal-cleanup
PR or issues related to the structure of the codebase, directories and refactors
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As several of us (particularly myself and @pearce8) have mentioned on numerous occasions, Python's duck typing system can be a pain to deal with.
To help with this, this PR adds extensive type hinting throughout Hatchet to help with understanding what is valid input/output for functions. Additionally, this PR adds support for mypy: the most widely used static type checker for Python.
mypy
makes use of the type hints added in this PR to determine whether code is written correctly, similar to how a compiler works for languages like C and C++.Besides type checking, this PR corrects numerous bugs that
mypy
revealed, ranging from minor typing issues due to reusing variables too much to functions not returning when they are supposed to (this one may actually be part of the cause of thesquash
issues you were having @slabasan). One important set of things thatmypy
pointed out is logic for Python 2. Since we are now officially supporting Python 3.5+, this logic is no longer needed, so I have removed any such logic thatmypy
detected.Finally, this PR adds mypy-based static type checking to our CI. Like
flake8
andblack
, this will only run for Python 3.9.Edit:
I got fed up with Black giving different formatting with different versions, so I added a devcontainer to Hatchet. This lets developers who user VSCode work in a Docker-based environment with the exact right versions of tools like black, flake8, and mypy.