-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
LazyImport.__instancecheck__, __subclasscheck__: Return False on ImportError #33017
Comments
Author: Matthias Koeppe |
Commit: |
New commits:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:5
It's not fast I suspect, as it tries an import and fails every time. But it is correct at least. |
Reviewer: Jonathan Kliem |
Dependencies: #32899 |
comment:8
I'll add some documentation to discuss performance |
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
|
comment:10
No patchbot yet, due to https://groups.google.com/g/sage-devel/c/epajAbPvg6s/m/-yWW1gFyCAAJ |
comment:11
Edited to remove unrelated failure.
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:16
Sorry, I completely forgot about this. I think figured to wait on a patchbot. You know, you can also ping me. I might not react, but I won't be annoyed. |
comment:17
Thanks! There was no urgency |
Changed branch from u/mkoeppe/lazyimport___instancecheck______subclasscheck____return_false_on_importerror to |
Changed commit from |
No object is an instance of a class that cannot be imported.
No class is a subclass of a class that cannot be imported.
Hence, we change
LazyImport
so that the special methods__instancecheck__
,__subclasscheck__
catchImportError
and just return False.(We do not use the stronger versions of these two statements: "No object is an instance of a class that has not been imported yet (i.e., the module name is not in
sys.modules
)." These are true only if there are no re-exports.)With this change to
LazyImport
, we have another instrument for modularization of code that usesisinstance
checks. (The use ofisinstance
with ABCs (#32566) is preferable because it avoids importing an otherwise unused implementation class.)Depends on #32899
CC: @tscrim @kliem
Component: refactoring
Author: Matthias Koeppe
Branch:
7adef96
Reviewer: Jonathan Kliem
Issue created by migration from https://trac.sagemath.org/ticket/33017
The text was updated successfully, but these errors were encountered: