-
Notifications
You must be signed in to change notification settings - Fork 192
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
👌 IMPROVE: Add typing to QueryBuilder #5063
👌 IMPROVE: Add typing to QueryBuilder #5063
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5063 +/- ##
===========================================
+ Coverage 80.43% 80.47% +0.05%
===========================================
Files 530 530
Lines 36946 36944 -2
===========================================
+ Hits 29712 29727 +15
+ Misses 7234 7217 -17
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
b5e1dcf
to
b347a30
Compare
7c391e7
to
1a14258
Compare
In preparation for migration to sqlalchemy 1.4
1a14258
to
f39c192
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just have a question about the type styling
aiida/orm/querybuilder.py
Outdated
NODE_CLS_TYPE = Type[Any] # pylint: disable=invalid-name | ||
PROJECT_TYPE = Union[str, dict, Sequence[Union[str, dict]]] # pylint: disable=invalid-name | ||
FILTER_TYPE = Dict[str, Any] # pylint: disable=invalid-name | ||
ROW_TYPE = Any # pylint: disable=invalid-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use here all-caps, but the CamelCase for PathItemType
further down? I see most built in types having CamelCase, so is that the standard? Should we change these to have the same style, even though they are "constants" and normally would be all-caps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know really lol, I think I say it somewhere else and kind of liked it, to distinguish these type annotation variables from regular one. But its not a big deal, so fine to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just find it confusing when reading the type annotations seeing PathItemType
and then ROW_TYPE
. Think if that is also RowType
it would be clearer and finding where the definition comes from is easy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries, changed it 👍
This PR principally adds typing to aiida/orm/querybuilder.py, and does a small bit of refactoring:
__init__
andappend
constructor variables more explicit, as opposed to relying onkwargs
which obfuscates the allowed inputs for the userself._aliased_path
variable, whose use in relation to thedirection
joining keyword was actually removed in v0.8 (nowdirection
is converted towith_outgoing
orwith_incoming
before storage, and similarly its value is converted from an int to a tag string)autotag=True
from.append
calls; another legacy bit of codeThe PR is intended as preparation for migration to sqlalchemy 1.4 (and dropping sqlalchemy-utils)