-
Notifications
You must be signed in to change notification settings - Fork 36
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
[WIP] Stub generation #176
base: master
Are you sure you want to change the base?
Commits on Dec 21, 2018
-
Configuration menu - View commit details
-
Copy full SHA for d91cbf3 - Browse repository at this point
Copy the full SHA d91cbf3View commit details -
This also retains the original constant value on the Constant class so that the stubbing can introspect its type. We could instead do the typing-annotation style formatting on the constant class, but this same logic is going to be needed for e.g., formatting function parameter types.
Configuration menu - View commit details
-
Copy full SHA for 182b6f1 - Browse repository at this point
Copy the full SHA 182b6f1View commit details -
Add stubs of module-level functions
This also retains the full function signature on functions so that we can get the Python typing annotations for args and return values correct.
Configuration menu - View commit details
-
Copy full SHA for 800869b - Browse repository at this point
Copy the full SHA 800869bView commit details -
Configuration menu - View commit details
-
Copy full SHA for d8d3e7d - Browse repository at this point
Copy the full SHA d8d3e7dView commit details
Commits on Dec 22, 2018
-
Configuration menu - View commit details
-
Copy full SHA for b5c8f07 - Browse repository at this point
Copy the full SHA b5c8f07View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1b14ae1 - Browse repository at this point
Copy the full SHA 1b14ae1View commit details -
Configuration menu - View commit details
-
Copy full SHA for fe62d77 - Browse repository at this point
Copy the full SHA fe62d77View commit details -
Configuration menu - View commit details
-
Copy full SHA for 49a99bd - Browse repository at this point
Copy the full SHA 49a99bdView commit details -
Configuration menu - View commit details
-
Copy full SHA for afdedb2 - Browse repository at this point
Copy the full SHA afdedb2View commit details
Commits on Dec 23, 2018
-
Configuration menu - View commit details
-
Copy full SHA for f2c4599 - Browse repository at this point
Copy the full SHA f2c4599View commit details -
This makes the virtualenv-installed setup work.
Configuration menu - View commit details
-
Copy full SHA for 948e8ee - Browse repository at this point
Copy the full SHA 948e8eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 30e9ca7 - Browse repository at this point
Copy the full SHA 30e9ca7View commit details -
Configuration menu - View commit details
-
Copy full SHA for ad9e737 - Browse repository at this point
Copy the full SHA ad9e737View commit details -
Configuration menu - View commit details
-
Copy full SHA for b6ff08f - Browse repository at this point
Copy the full SHA b6ff08fView commit details -
Module prefix all typing annotation strings for import ease
This makes it a lot easier because we can just add a `typing` import to the top of the `.pyi` file and forget about everything else.
Configuration menu - View commit details
-
Copy full SHA for 82c4cc9 - Browse repository at this point
Copy the full SHA 82c4cc9View commit details -
Configuration menu - View commit details
-
Copy full SHA for d967c62 - Browse repository at this point
Copy the full SHA d967c62View commit details -
Handling current-module-prefix stripping for stub generation
The problem here is that we need class/struct/etc. references within the module being annotated to not have the module prefix, because otherwise we just get unresolvable typing references. We also need all of these to be forward references (i.e., strings) unless we want to do some kind of dependency ordering, which I don't. I'm not a fan of doing this with a global, but the other solutions are much more complicated. Maybe we can make a stubber state class instead of this, but it's not obvious how much better that would be.
Configuration menu - View commit details
-
Copy full SHA for 0cedbb1 - Browse repository at this point
Copy the full SHA 0cedbb1View commit details -
Configuration menu - View commit details
-
Copy full SHA for c0d06f4 - Browse repository at this point
Copy the full SHA c0d06f4View commit details
Commits on Dec 25, 2018
-
Handle indirect GI module dependencies for imports
While there's dependency information in the namespace class, it's not reliable when we need to have all relevant modules in the current namespace for name resolution. The solution here is to constantly update a list of modules that have been referenced by current-module annotations, since that's what mypy, etc. are going to need. This change also means that we can't write import order until the end of the stubbing, so we're now keeping the stubs in a StringIO.
Configuration menu - View commit details
-
Copy full SHA for b5e6591 - Browse repository at this point
Copy the full SHA b5e6591View commit details -
This doesn't cover everything, but now at least we get GType, which was causing a lot of issues.
Configuration menu - View commit details
-
Copy full SHA for 61b98c6 - Browse repository at this point
Copy the full SHA 61b98c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1c5ea23 - Browse repository at this point
Copy the full SHA 1c5ea23View commit details -
Configuration menu - View commit details
-
Copy full SHA for f365caf - Browse repository at this point
Copy the full SHA f365cafView commit details -
Configuration menu - View commit details
-
Copy full SHA for c1896b1 - Browse repository at this point
Copy the full SHA c1896b1View commit details -
Ignore typing errors for constructors
Firstly, it's worth noting that this only ignores the typing error. Things that call these APIs will still be checked! The problem is that the checking may be incorrect because of the API itself. There's a long discussion about this and related Liskov issues at: python/mypy#1237 The short version is that this API is wrong-ish, but there's no mechanism within mypy to correctly annotate what's going on here. There *is* some of this around, because mypy treats __init__ and __new__ differently itself, but we can't apply that treatment to our constructors. This would be better if we actually knew which methods were constructors, instead of the name-based guessing here... but that's way too much complexity for me right now.
Configuration menu - View commit details
-
Copy full SHA for 656afda - Browse repository at this point
Copy the full SHA 656afdaView commit details
Commits on Dec 26, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 140dcf5 - Browse repository at this point
Copy the full SHA 140dcf5View commit details -
Reuse enum stub generation code for flags
These are functionally identical anyway, and are *almost* the same as the generic class stubber.
Configuration menu - View commit details
-
Copy full SHA for d915b89 - Browse repository at this point
Copy the full SHA d915b89View commit details -
Configuration menu - View commit details
-
Copy full SHA for eb086d9 - Browse repository at this point
Copy the full SHA eb086d9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 51e5bd3 - Browse repository at this point
Copy the full SHA 51e5bd3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 05fb137 - Browse repository at this point
Copy the full SHA 05fb137View commit details
Commits on Dec 30, 2018
-
Handle explicit NoneType types differently
These are special cases for some base types lacking introspection information. Since nothing else seems to have this issue other than low-level GObject types, we'll treat this as a weird case. This gets rid of mypy errors like: GObject.pyi:1416: error: Name 'NoneType' is not defined in module-level definitions for e.g., GBoxed, GPointer, etc.
Configuration menu - View commit details
-
Copy full SHA for afa7c5d - Browse repository at this point
Copy the full SHA afa7c5dView commit details
Commits on Dec 31, 2018
-
Use the builtins module to explicitly namespace built-in types
This isn't a generic solution for shadowing... that would require actual parsing and tricks. However, in practice the risky shadowing here happens when e.g., a class implements def int(self) -> int: ... and everything breaks. This works around that in a somewhat-inelegant but basically-correct kind of way.
Configuration menu - View commit details
-
Copy full SHA for 0cdb17e - Browse repository at this point
Copy the full SHA 0cdb17eView commit details
Commits on Jan 11, 2019
-
Remove old-style variable annotations and string-ified class names
According to mypy, these aren't necessary in stub files.
Configuration menu - View commit details
-
Copy full SHA for 5342f75 - Browse repository at this point
Copy the full SHA 5342f75View commit details -
Configuration menu - View commit details
-
Copy full SHA for 462a2a8 - Browse repository at this point
Copy the full SHA 462a2a8View commit details
Commits on Jan 13, 2019
-
Configuration menu - View commit details
-
Copy full SHA for cd18e22 - Browse repository at this point
Copy the full SHA cd18e22View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8246f86 - Browse repository at this point
Copy the full SHA 8246f86View commit details -
Annotate GObject.Enum and GObject.Flags as also being integers
They support common integer methods, so this is definitely reasonable.
Configuration menu - View commit details
-
Copy full SHA for 8ae025e - Browse repository at this point
Copy the full SHA 8ae025eView commit details -
flake8 is trying to do the right thing here, but in this instance we're dealing with getting an actual type, so the "use isinstance instead" error really isn't helpful or correct.
Configuration menu - View commit details
-
Copy full SHA for 17042a5 - Browse repository at this point
Copy the full SHA 17042a5View commit details
Commits on Aug 10, 2019
-
Configuration menu - View commit details
-
Copy full SHA for fde7826 - Browse repository at this point
Copy the full SHA fde7826View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3641107 - Browse repository at this point
Copy the full SHA 3641107View commit details -
main: Don't hard-require apt libraries
These aren't in the module requirements, and aren't installed by default on non-Debian-based systems.
Configuration menu - View commit details
-
Copy full SHA for 7db61ad - Browse repository at this point
Copy the full SHA 7db61adView commit details -
Ignore spurious nodes in private member check
The check for whether a record is private assumes a fixed child node structure that isn't the case in some environments. This patch tries to keep the spirit of the check by filtering out all known-unimportant child nodes and simply checking whether there's anything left. The expected unimportant nodes are: * empty text nodes containing formatting white-space * source-position elements that map the member to the original source file neither of which indicate that the member actually needs to be annotated.
Configuration menu - View commit details
-
Copy full SHA for 14855eb - Browse repository at this point
Copy the full SHA 14855ebView commit details
Commits on Aug 13, 2019
-
Add support for ignoring type errors in class inheritance
This is needed for e.g., classes that inherit from both Atk.Object and Atk.Action, which both define methods like `get_description` with very different signatures.
Configuration menu - View commit details
-
Copy full SHA for dde6e34 - Browse repository at this point
Copy the full SHA dde6e34View commit details -
Allow kwargs for GObject constructors
GObject-derived widgets always accept keyword args for setting GObject properties. Ideally we'd check that the kwargs matched the object's properties, but for now we'll just accept all kwargs to avoid the type errors.
Configuration menu - View commit details
-
Copy full SHA for 9ef2d3f - Browse repository at this point
Copy the full SHA 9ef2d3fView commit details -
Configuration menu - View commit details
-
Copy full SHA for cd92bba - Browse repository at this point
Copy the full SHA cd92bbaView commit details -
stubs: Add a way to provide module-level aliases
This is currently only for GObject, but there's several cases where backwards-compatible aliases have been provided.
Configuration menu - View commit details
-
Copy full SHA for a6dffe8 - Browse repository at this point
Copy the full SHA a6dffe8View commit details
Commits on Aug 14, 2019
-
Configuration menu - View commit details
-
Copy full SHA for ccf067a - Browse repository at this point
Copy the full SHA ccf067aView commit details -
stubs: Add a range of constructor-type names
Ideally this would come from the GI constructor information, but we don't maintain that through to the point of use here yet. This list should be able to be removed with some work in the future though.
Configuration menu - View commit details
-
Copy full SHA for f3ed013 - Browse repository at this point
Copy the full SHA f3ed013View commit details
Commits on Aug 16, 2019
-
stubs: Add new module for manual stub additions and handle in generation
Object.Property and Object.Signal are the main two missing parts for general use, and both require hand-written stub information. The Property stub here is probably wrong in various ways and could definitely be a lot better, but it's better than nothing.
Configuration menu - View commit details
-
Copy full SHA for eca1c0e - Browse repository at this point
Copy the full SHA eca1c0eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 992976e - Browse repository at this point
Copy the full SHA 992976eView commit details