-
Notifications
You must be signed in to change notification settings - Fork 76
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
chore: add types to most of the uproot.source
module
#996
Conversation
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.
Great, thanks! You can merge this as-is. My suggested commits below are just taking the typing further, which is optional.
All of the int
argument types are a little dubious: these arguments sometimes take np.int64
and similar, depending on where the integer came from, and that's technically not an int
. For runtime type-checking, I use
isinstance(x, numbers.Integral)
which takes NumPy integers as well as Python int
, but I think that filling up these files with : numbers.Integral
and especially : list[(numbers.Integral, numbers.Integral)]
would obscure it.
def handle_no_multipart( | ||
self, | ||
source: uproot.source.chunk.Source, | ||
ranges: list[(int, int)], | ||
futures, | ||
results, | ||
): |
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.
See handle_multipart
for comments on futures
and results
.
Co-authored-by: Jim Pivarski <jpivarski@users.noreply.github.com>
* origin/source-typing: style: pre-commit fixes
For posterity, I don't think mypy understands the integral type. Also, there's the os.PathLike interface for non-str/bytes types, so we could define that in a local types module. |
Add types to most of the sources module.
Only added types where I was sure of the type.
I left things such as urls, file paths, etc. untyped instead of typing them as
str
since user may pass apathlib
path or similar.