Skip to content
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 stubs for python-datemath #5765

Merged
merged 10 commits into from
Jan 11, 2023
Merged

Add stubs for python-datemath #5765

merged 10 commits into from
Jan 11, 2023

Conversation

kasium
Copy link
Contributor

@kasium kasium commented Jul 12, 2021

No description provided.

@kasium kasium marked this pull request as draft July 12, 2021 15:06
@kasium
Copy link
Contributor Author

kasium commented Jul 12, 2021

Maybe somebody can support here:

stubs/python-datemath/datemath/__init__.pyi (3.9): pytype.load_pytd.BadDependencyError: Can't find pyi for 'arrow', referenced from 'datemath'
stubs/python-datemath/datemath/helpers.pyi (3.9): pytype.load_pytd.BadDependencyError: Can't find pyi for 'arrow', referenced from 'datemath.helpers'

python-datemath has a dependency on arrow which has type hints natively.

@srittau
Copy link
Collaborator

srittau commented Jul 12, 2021

I suspect (but haven't verified) that this is a shortcoming in our pytype tests that don't install the dependencies when testing third-party stubs.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jul 12, 2021

@kasium these are the CI errors I'd look at for now (stubtest): https://github.com/python/typeshed/pull/5765/checks?check_run_id=3047893267

typeshed currently assumes that all stub dependencies are typeshed stub packages, and that's the reason for all the remaining CI failures (check_consistent, mypy, pytype, pyright). We talked about relaxing this in at least #5618 and it's something we definitely should do — but we haven't yet and you might have to bear with us for a little bit while we figure it out :-)

@kasium
Copy link
Contributor Author

kasium commented Jul 12, 2021

@hauntsaninja thanks a lot for the help. I'll wait till you solve it on your side and then continue with this PR :-)

Please let me know if I can help you somehow

@srittau
Copy link
Collaborator

srittau commented Feb 2, 2022

What's the current status of this? I think we should try whether the errors were resolved.

@kasium
Copy link
Contributor Author

kasium commented Feb 2, 2022

@srittau this is still blocked, since AFAIK no 3rd party dependencies can be used, right?

@srittau srittau marked this pull request as ready for review February 2, 2022 15:05
@srittau srittau added the status: deferred Issue or PR deferred until some precondition is fixed label Feb 2, 2022
@srittau srittau marked this pull request as draft February 2, 2022 15:06
@srittau
Copy link
Collaborator

srittau commented Feb 2, 2022

I see. I added the "deferred" label so we track this.

@github-actions

This comment has been minimized.

AlexWaygood added a commit to AlexWaygood/stub_uploader that referenced this pull request Jan 8, 2023
This PR adds four new items to the "non-types dependencies whitelist", in preparation for non-types dependencies being allowed in typeshed.

## `arrow`

Typeshed has had a PR open to add stubs for `python-datemath` for a long time now: python/typeshed#5765. The `arrow` package is fundamental to `python-datemath`, so the PR realistically can't be merged without having `arrow` as a dependency. `arrow` only depends on `python-dateutils` and, on Python <3.8, `typing_extensions`: https://github.com/arrow-py/arrow/blob/74a759b88447b6ecd9fd5de610f272c8fb6130a2/setup.py#L25-L28. It is actively maintained, and has 8.2k stars on GitHub. `arrow` is the sole dependency of `python-datemath`: https://github.com/nickmaccarthy/python-datemath/blob/6d047b3cc4e357d83b50e7433c812994e21c3ffb/setup.py#L86.

## `click`

Typeshed has a PR open to add stubs for the `click-default-group`: python/typeshed#9304 Similar to the PR adding stubs for `python-datemath`, there's not much point merging the PR unless it can declare a dependency on `click`; `click` is just too fundamental to the package. `click` is obviously a hugely popular CLI framework for Python. It's only dependencies are `colorama` (if you're on Windows) and `importlib-metadata` (if you're on Python <3.8): https://github.com/pallets/click/blob/9595a190d79e80945f6827a79f12937a8212f307/setup.py#L5-L8. `click` is the sole dependency of `click-default-group`: https://github.com/click-contrib/click-default-group/blob/b671ae5325d186fe5ea7abb584f15852a1e931aa/setup.py#L52.

## `Flask` and `Werkzeug`

Typeshed has stubs for several `Flask` plugins. Being able to declare a dependency on `Flask` would be useful for [`Flask-Cors`](https://github.com/python/typeshed/blob/41de5317b5008719c899b0ca61f9fd37b774cade/stubs/Flask-Cors/flask_cors/core.pyi#L10) and [`Flask-Migrate`](https://github.com/python/typeshed/blob/41de5317b5008719c899b0ca61f9fd37b774cade/stubs/Flask-Migrate/flask_migrate/__init__.pyi#L10) in particular. `Flask` is declared as a dependency of both [`Flask-Cors`](https://github.com/corydolphin/flask-cors/blob/cad70b3298fdd5605e1c09628050e2598f6f7e0e/requirements.txt#L1) and [`Flask-Migrate`](https://github.com/miguelgrinberg/Flask-Migrate/blob/a7714530453d6cc1b882944ec4f3002b6745e9c5/setup.cfg#L28) at runtime. `Flask` is obviously a hugely popular web framework for Python, that is actively maintained. It has a few more dependencies at runtime than the others on this list, but still not very many: https://github.com/pallets/flask/blob/836866dc19218832cf02f8b04911060ac92bfc0b/setup.py#L6-L12.

Typeshed's stubs for `Flask-Cors` would also benefit from being able to declare a dependency on `Werkzeug`: https://github.com/python/typeshed/blob/41de5317b5008719c899b0ca61f9fd37b774cade/stubs/Flask-Cors/flask_cors/core.pyi#L12. The benefit to this one would be fairly small, but it also seems silly to _disallow_ declaring a dependency on `Werkzeug`, since it's already a dependency of `Flask` at runtime, and is just as actively maintained as `Flask`.
JelleZijlstra pushed a commit to typeshed-internal/stub_uploader that referenced this pull request Jan 8, 2023
…g` (#85)

This PR adds four new items to the "non-types dependencies whitelist", in preparation for non-types dependencies being allowed in typeshed.

## `arrow`

Typeshed has had a PR open to add stubs for `python-datemath` for a long time now: python/typeshed#5765. The `arrow` package is fundamental to `python-datemath`, so the PR realistically can't be merged without having `arrow` as a dependency. `arrow` only depends on `python-dateutils` and, on Python <3.8, `typing_extensions`: https://github.com/arrow-py/arrow/blob/74a759b88447b6ecd9fd5de610f272c8fb6130a2/setup.py#L25-L28. It is actively maintained, and has 8.2k stars on GitHub. `arrow` is the sole dependency of `python-datemath`: https://github.com/nickmaccarthy/python-datemath/blob/6d047b3cc4e357d83b50e7433c812994e21c3ffb/setup.py#L86.

## `click`

Typeshed has a PR open to add stubs for the `click-default-group`: python/typeshed#9304 Similar to the PR adding stubs for `python-datemath`, there's not much point merging the PR unless it can declare a dependency on `click`; `click` is just too fundamental to the package. `click` is obviously a hugely popular CLI framework for Python. It's only dependencies are `colorama` (if you're on Windows) and `importlib-metadata` (if you're on Python <3.8): https://github.com/pallets/click/blob/9595a190d79e80945f6827a79f12937a8212f307/setup.py#L5-L8. `click` is the sole dependency of `click-default-group`: https://github.com/click-contrib/click-default-group/blob/b671ae5325d186fe5ea7abb584f15852a1e931aa/setup.py#L52.

## `Flask` and `Werkzeug`

Typeshed has stubs for several `Flask` plugins. Being able to declare a dependency on `Flask` would be useful for [`Flask-Cors`](https://github.com/python/typeshed/blob/41de5317b5008719c899b0ca61f9fd37b774cade/stubs/Flask-Cors/flask_cors/core.pyi#L10) and [`Flask-Migrate`](https://github.com/python/typeshed/blob/41de5317b5008719c899b0ca61f9fd37b774cade/stubs/Flask-Migrate/flask_migrate/__init__.pyi#L10) in particular. `Flask` is declared as a dependency of both [`Flask-Cors`](https://github.com/corydolphin/flask-cors/blob/cad70b3298fdd5605e1c09628050e2598f6f7e0e/requirements.txt#L1) and [`Flask-Migrate`](https://github.com/miguelgrinberg/Flask-Migrate/blob/a7714530453d6cc1b882944ec4f3002b6745e9c5/setup.cfg#L28) at runtime. `Flask` is obviously a hugely popular web framework for Python, that is actively maintained. It has a few more dependencies at runtime than the others on this list, but still not very many: https://github.com/pallets/flask/blob/836866dc19218832cf02f8b04911060ac92bfc0b/setup.py#L6-L12.

Typeshed's stubs for `Flask-Cors` would also benefit from being able to declare a dependency on `Werkzeug`: https://github.com/python/typeshed/blob/41de5317b5008719c899b0ca61f9fd37b774cade/stubs/Flask-Cors/flask_cors/core.pyi#L12. The benefit to this one would be fairly small, but it also seems silly to _disallow_ declaring a dependency on `Werkzeug`, since it's already a dependency of `Flask` at runtime, and is just as actively maintained as `Flask`.
@github-actions

This comment has been minimized.

@Avasam
Copy link
Collaborator

Avasam commented Jan 8, 2023

I suspect (but haven't verified) that this is a shortcoming in our pytype tests that don't install the dependencies when testing third-party stubs.

They are installed, but pytype won't use them: #9459 (comment)

There's possible workarounds (silence the error or ignore the file in pytype), but I think we're currently waiting to see if pytype can provide a non-hacky solution with an update?

Edit: Just realized that comment was from last year. Still the issue I linked is currently a blocker with pytype.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexWaygood AlexWaygood removed the status: deferred Issue or PR deferred until some precondition is fixed label Jan 10, 2023
@AlexWaygood AlexWaygood marked this pull request as ready for review January 10, 2023 23:51
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kasium! Sorry this took so long!

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit 5e1632b into python:main Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants