[weasyprint] Add stubs for WeasyPrint 69.0#15349
Conversation
This comment has been minimized.
This comment has been minimized.
Yes, that's perfectly fine. |
|
Thanks for the quick reply! Then I will see to it that at least my use case is completely mapped (and the checks run green, I suppose), and would then change this PR to ready. |
|
Well, I haven't forgotten about this, and funnily enough, today the organisation behind WeasyPrint sort of doubled down on the fact they don't like type hints: https://www.courtbouillon.org/blog/00064-types/ Meaning this PR could become very relevant if I ever get the time to implement something, which I still hope I do soon-ish. |
|
Hi! WeasyPrint has a pretty stable, official public API. All the other functions are not supposed to be used by WeasyPrint users, and regularly break between versions. I don’t know what the best solution is in this case, but I think that adding type hints only for this public API is probably easier and better. |
|
That would also be sufficient for me. The current state of this PR is auto-generated, by the tool provided in the Typeshed repo. Does that mean I could remove a lot of the current files, and only include those corresponding to the Python files containing the public API? |
I think so. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
A hint to maybe help this get over the finish line: I've just opened #16011 to add some guidance about missing dependencies. For your convenience, I've copied it here: When a third-party stub package depends on another package, there are several
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks for offering, but we generally prefer to keep the commits non-squashed. We will squash merge at the end anyway, and that makes it easier for us to review single steps. |
|
Some of the stubtest error can be fixed by setting If you have incomplete modules (i.e. modules that don't have all items), you can use this construct (usually at the end of files): # beginning of file
from _typeshed import Incomplete
#end of file
def __getattr__(name: str, /): ... # incomplete moduleSimilarly, for incomplete classes you can use: class Foo:
...
def __getattr__(self, name: str, /): ... # incomplete classIf you deliberately don't want to include an item that's flagged by stubtest, you can also add it to the allowlist mentioned above, with a short comment explaining why that is. (Again, see other allowlists in typeshed.) |
This reverts commit 190b8a6. # Conflicts: # stubs/weasyprint/weasyprint/css/counters.pyi
|
Per the suggestion in #15349 (comment), I've just restored all the other stub files. Does that mean that I now won't need to set |
This comment has been minimized.
This comment has been minimized.
|
Correct, you don't need the partial-stub setting. |
|
The rest of the mypy failures look very manageable. I would just suppress the untyped decorator warnings for now (using |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I might have reduced it to three error messages: This seems to be some problem with a |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This adds a really small set of annotations for WeasyPrint 69.0.
I use WeasyPrint in one of my projects, use only a few methods, but would like to have my type checker working for these.
Is it okay if a submit this to typeshed, even though it will be only partially annotated?