-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add type hints to openslide
package
#260
Commits on Oct 18, 2024
-
add typing for main interface file
Signed-off-by: Sam Maxwell <sam@groundtruthlabs.com> Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for f31c8b2 - Browse repository at this point
Copy the full SHA f31c8b2View commit details -
Signed-off-by: Sam Maxwell <sam@groundtruthlabs.com>
Configuration menu - View commit details
-
Copy full SHA for f4b8131 - Browse repository at this point
Copy the full SHA f4b8131View commit details -
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for 5032e23 - Browse repository at this point
Copy the full SHA 5032e23View commit details -
Enable type checking for entire openslide package
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for a6c2f82 - Browse repository at this point
Copy the full SHA a6c2f82View commit details
Commits on Oct 19, 2024
-
Return subclass from AbstractSlide.__enter__()
AbstractSlide subclasses will always return their specific type from this method. Ensure the type system knows this. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for e52cb3a - Browse repository at this point
Copy the full SHA e52cb3aView commit details -
Disallow bytes in filename arguments
bytes will not work in at least one case (the OpenSlide initializer), are not documented to work, and the type annotations are currently inconsistent about accepting it. For now, forbid it everywhere for consistency. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for 87495ba - Browse repository at this point
Copy the full SHA 87495baView commit details -
Explicitly hint the possible open_slide() return types
open_slide() can't return any possible AbstractSlide subclass, only the two that it's documented to return. Make that explicit in the type hint. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for 8c26361 - Browse repository at this point
Copy the full SHA 8c26361View commit details -
Loosen mapping type guarantees
Avoid overcommitting to internal implementation details in the types being returned. It's sufficient to say that the property and associated image maps implement Mapping. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for 076e96f - Browse repository at this point
Copy the full SHA 076e96fView commit details -
We don't want to encourage library users to duck-type a replacement for OpenSlideCache, since any replacement would inherently need to make assumptions about our implementation details. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for dccce62 - Browse repository at this point
Copy the full SHA dccce62View commit details -
Explicitly check for closed ImageSlide
When an operation is performed on a closed ImageSlide, we've historically raised an AttributeError upon dereferencing None. Add proper checks so the type system understands what we're doing, raising ValueError as lowlevel does. This is not an API change because it only affects invalid caller behavior. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for cfd1663 - Browse repository at this point
Copy the full SHA cfd1663View commit details -
deepzoom: revert unrolling of _get_tile_info()
We don't need to avoid generator expressions to keep the type checker happy; we can just assert that the resulting tuples have the correct length. This lets us avoid carrying redundant unrolled code. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for f24c1dd - Browse repository at this point
Copy the full SHA f24c1ddView commit details -
deepzoom: fix level_dimensions type hint
level_dimensions is always a tuple of 2-tuples. Prove this to the type checker. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for 0d675d6 - Browse repository at this point
Copy the full SHA 0d675d6View commit details -
Revert unrolling of ImageSlide.read_region()
Keep the type checker happy by asserting the correct tuple lengths rather than unrolling generator expressions. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for 981684b - Browse repository at this point
Copy the full SHA 981684bView commit details -
Drop redundant return type hint
__init__() methods don't need a return type hint unless they take no arguments. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for f1d02fc - Browse repository at this point
Copy the full SHA f1d02fcView commit details -
Narrow some ImageSlide property types
ImageSlide is hardcoded to a single level, and the level_count property and get_best_level_for_downsample() return types already reflect this. Reduce the level_dimensions() and level_downsamples() return types to 1-tuples. In the latter case we can't reduce to a Literal because literal floats are disallowed. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
Configuration menu - View commit details
-
Copy full SHA for 0efc25b - Browse repository at this point
Copy the full SHA 0efc25bView commit details