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

Use TypedDict argument unpacking for setuptools/distutils's setup #13400

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Jan 14, 2025

Less repetition, feels cleaner, and can be extended.
I also plan on using this technique in setuptools directly (pypa/setuptools#2345 (comment)) after which it'll be really close to be ready to be marked as py.typed

Edit: hmm, I have to add setuptools._distutils.core, kinda muddles my "less repetition" point above...
Edit 2: Unpacked TypedDict as kwargs doesn't seem to work as expected form the mypy_primer hit. Maybe that's something to be added to the spec. Or a mypy issue, idk

This comment has been minimized.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

comtypes (https://github.com/enthought/comtypes)
- comtypes/test/setup.py:2: error: Cannot find implementation or library stub for module named "distutils.core"  [import-not-found]
- comtypes/test/setup.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ comtypes/test/setup.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ comtypes/test/setup.py:6: error: Unexpected keyword argument "console" for "setup"  [call-arg]

streamlit (https://github.com/streamlit/streamlit)
+ lib/setup.py:103:1: error: Unexpected keyword argument "project_urls" for "setup"  [call-arg]
+ lib/setup.py:103:1: error: Unexpected keyword argument "python_requires" for "setup"  [call-arg]
+ lib/setup.py:103:1: error: Unexpected keyword argument "install_requires" for "setup"  [call-arg]
+ lib/setup.py:103:1: error: Unexpected keyword argument "extras_require" for "setup"  [call-arg]
+ lib/setup.py:103:1: error: Unexpected keyword argument "zip_safe" for "setup"  [call-arg]
+ lib/setup.py:103:1: error: Unexpected keyword argument "entry_points" for "setup"  [call-arg]

apprise (https://github.com/caronc/apprise)
+ setup.py:64: error: Unexpected keyword argument "install_requires" for "setup"  [call-arg]
+ setup.py:64: error: Unexpected keyword argument "entry_points" for "setup"  [call-arg]
+ setup.py:64: error: Unexpected keyword argument "python_requires" for "setup"  [call-arg]
+ setup.py:64: error: Unexpected keyword argument "setup_requires" for "setup"  [call-arg]

antidote (https://github.com/Finistere/antidote)
+ setup.py:11: error: Unexpected keyword argument "use_scm_version" for "setup"  [call-arg]
+ setup.py:11: error: Unexpected keyword argument "python_requires" for "setup"  [call-arg]
+ setup.py:11: error: Unexpected keyword argument "install_requires" for "setup"  [call-arg]
+ setup.py:11: error: Unexpected keyword argument "zip_safe" for "setup"  [call-arg]

arviz (https://github.com/arviz-devs/arviz)
+ setup.py:48: error: Unexpected keyword argument "install_requires" for "setup"  [call-arg]
+ setup.py:48: error: Unexpected keyword argument "extras_require" for "setup"  [call-arg]
+ setup.py:48: error: Unexpected keyword argument "python_requires" for "setup"  [call-arg]

schemathesis (https://github.com/schemathesis/schemathesis)
-   File "/tmp/mypy_primer/old_mypy/venv/bin/mypy", line 8, in <module>
+   File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
-   File "/tmp/mypy_primer/old_mypy/venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
+   File "/tmp/mypy_primer/new_mypy/venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry

cwltool (https://github.com/common-workflow-language/cwltool)
+ setup.py:86:1: error: Unexpected keyword argument "install_requires" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "extras_require" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "python_requires" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "use_scm_version" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "setup_requires" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "test_suite" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "tests_require" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "entry_points" for "setup"  [call-arg]
+ setup.py:86:1: error: Unexpected keyword argument "zip_safe" for "setup"  [call-arg]

materialize (https://github.com/MaterializeInc/materialize)
+ misc/python/materialize/setup.py:19: error: Unexpected keyword argument "install_requires" for "setup"  [call-arg]
+ ci/deploy/pypi.py:27: error: Module has no attribute "run_setup"  [attr-defined]
- ci/deploy/pypi.py:10: error: Cannot find implementation or library stub for module named "distutils.core"  [import-not-found]
- ci/deploy/pypi.py:10: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ misc/python/materialize/cli/ci_coverage_pr_report.py:17: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

httpx-caching (https://github.com/johtso/httpx-caching)
+ setup.py:38: error: Unexpected keyword argument "python_requires" for "setup"  [call-arg]
+ setup.py:38: error: Unexpected keyword argument "project_urls" for "setup"  [call-arg]
+ setup.py:38: error: Unexpected keyword argument "zip_safe" for "setup"  [call-arg]
+ setup.py:38: error: Unexpected keyword argument "install_requires" for "setup"  [call-arg]
+ setup.py:38: error: Unexpected keyword argument "extras_require" for "setup"  [call-arg]

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/sourcecode/setuptools_auto.py:11: error: Unused "type: ignore" comment  [unused-ignore]

@JelleZijlstra
Copy link
Member

I think the new errors is expected, currently Unpack[] in kwargs doesn't support extra **kwargs. PEP 728 should make that possible. Until that becomes available I don't think we can make this change.

@Avasam
Copy link
Collaborator Author

Avasam commented Jan 15, 2025

Thanks for pointing me to the appropriate PEP Jelle!
The most relevant section seems to be this one: https://peps.python.org/pep-0728/#interaction-with-unpack

I considered the deffered label, but given that PEP is still in draft and I'm realistically likely to get setuptools out of typeshed in 2025, I'll just close instead.

@Avasam Avasam closed this Jan 15, 2025
@Avasam Avasam deleted the Use-TypedDict-argument-unpacking-for-setuptools-distutils's-setup branch January 15, 2025 22:52
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.

2 participants