-
Notifications
You must be signed in to change notification settings - Fork 181
feat: add basic type stubs #221
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
Conversation
|
@AlexVonB @chrispy-snps friendly bump in case you missed this 🙂 |
|
Sorry for the wait! Quick question before I merge this: is there a sensible way to test this in our pipeline? Or even manually? I just would like to check this branch out, do something that confirms that this works, and the merge it. |
|
Let me fire up a codespace and have a playaround - I can say they work as we're using them in this repository and so if I remove that file then I expect you should be able to replicate that to some degree, but I'm not sure how much it will just work when you're running |
|
ok so it looks like an easy way to get very basic checking is to just run For more strict type checking without requiring the whole codebase to immediately use types, we should be fine to add a dedicated Python file that we can run |
|
The advantage of a sidefile-based approach is that it imposes no constraint on the Python version. The disadvantage is that it requires more work to keep it synchronized with the code itself, especially when code is refactored and functions get changed/added/deleted. PEP 484 typing annotations were introduced in Python 3.5, which was released ten years ago. Perhaps it is time to raise our minimum required Python version and modernize our code? |
|
@chrispy-snps I think that is a good idea, but I expect it would take longer than shipping these types which is why my recommendation is to do this in the short-term so that downstream consumers (like myself) can start relying on the types from the package rather than having to maintain them ourselves (especially as I expect dropping Python versions will require a new major version of the package) |
|
@G-Rath - is your thinking to release the *.pyi files now in a minor release, then replace them with inline typing annotations (i.e., delete the *.pyi files) in a future major release? |
|
@chrispy-snps yup exactly |
f793b87 to
b54501e
Compare
1f50d19 to
c3a85b2
Compare
5ee2435 to
4ed274b
Compare
|
@AlexVonB @chrispy-snps I think this should be very good to go now! I've introduced a new Some general notes:
I'm happy to do follow-ups for these, I just think the current types are a good starting point to ship first |
|
Looks good to me! @chrispy-snps we should take extra care with future new options: they should be not only added to the CLI, but now also to the types. Maybe we could add a merge request template for this? If you are fine with this MR, please merge it! :) @G-Rath Thank you very much for your work and patience! It is greatly appreciated! |
|
@AlexVonB - I'm on vacation for the next week. If you have time to spin a new public build, that's great! If not, I can do it when I get back. |
|
@chrispy-snps done! :) have a nice vacation! |
|
@AlexVonB thanks for the release, but I think the package needs to include a From https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages:
I have opened #235 adding this |
The type definitions have been landed upstream so we no longer need to maintain them here ~(this is blocked until [a new version is released with a `py.typed` file](matthewwithanm/python-markdownify#221 (comment)
As discussed this adds an initial
pyifile that typesmarkdownifyenough that checkers likemypyshould be happy for consumers to usemarkdownifyin a strongly typed context.The types are by no means compete, but from here they can be easily iterated on and improved - I've not included setting up
mypychecking as part of this as my understanding is it won't do anything given this is a single fileResolves #215