Consider using stubdefaulter
#1213
hunterhogan
started this conversation in
Ideas
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
stubdefaulter is "A tool for automatically adding default values to Python type stubs." and is one of the tools used by typeshed.
(I am not affiliated with Python, typeshed, stubdefaulter, JelleZijlstra, or their friends or even their cats.)
typeshed example
Source.
Also in "requirements-test.txt"
stubdefaulter and pandas-stubs
I ran stubdefaulter on pandas-stubs and the result was
Example diff
Before
After
Profound changes!
Obviously, this will automate 30-40% of your tasks and AI will eventually replace human programmers. In all three overloads, the only change was to become
index: Literal[True] = True
. This seems like a relatively safe tool (as in it won't cause problems) that could automate some highly mundane tasks. Furthermore, because it is based on code behavior, it could catch things that static analysis can't.View all 222 changes
I made a fork and branch with only the changes made by stubdefaulter (permalink to commit), so you can compare the changes.
The environment in which I ran stubdefaulter
I don't know for sure you will have the same outcome, but I tried to run stubdefaulter in an environment that is similar to where you would use it. Comparing apples to apple_like, if you will.
pip list
section, below.)Now run stubdefaulter
Run the tests again to see if stubdefaulter induced new problems.
The same?
The tests look the same to me.
Annex:
pip list
For completeness:
(.venv) C:\clones\pandas-stubs>pip list Package Version Editable project location --------------------- ----------------- ------------------------- beautifulsoup4 4.13.4 black 25.1.0 blosc2 3.3.3 certifi 2025.4.26 cfgv 3.4.0 charset-normalizer 3.4.2 click 8.2.0 colorama 0.4.6 contourpy 1.3.2 cycler 0.12.1 defusedxml 0.7.1 distlib 0.3.9 et_xmlfile 2.0.0 filelock 3.18.0 fonttools 4.58.0 greenlet 3.2.2 html5lib 1.1 identify 2.6.10 idna 3.10 importlib_resources 6.5.2 iniconfig 2.1.0 isort 6.0.1 Jinja2 3.1.6 kiwisolver 1.4.8 libcst 1.7.0 loguru 0.7.3 lxml 5.4.0 MarkupSafe 3.0.2 matplotlib 3.10.3 msgpack 1.1.0 mypy 1.15.0 mypy_extensions 1.1.0 ndindex 1.9.2 nodeenv 1.9.1 numexpr 2.10.2 numpy 2.2.5 odfpy 1.4.1 openpyxl 3.1.5 packaging 25.0 pandas 2.2.3 pandas-stubs 2.2.3.250308 C:\clones\pandas-stubs pastel 0.2.1 pathspec 0.12.1 pillow 11.2.1 pip 25.1.1 platformdirs 4.3.7 pluggy 1.6.0 poethepoet 0.34.0 pre_commit 4.2.0 py-cpuinfo 9.0.0 pyarrow 20.0.0 pyparsing 3.2.3 pyreadstat 1.2.8 pyright 1.1.400 pytest 8.3.5 python-calamine 0.3.2 python-dateutil 2.9.0.post0 pytz 2025.2 pyxlsb 1.0.10 PyYAML 6.0.2 requests 2.32.3 scipy 1.15.2 six 1.17.0 soupsieve 2.7 SQLAlchemy 2.0.41 stubdefaulter 0.1.0 tables 3.10.2 tabulate 0.9.0 termcolor 3.1.0 tomli 2.2.1 types-python-dateutil 2.9.0.20241206 types-pytz 2025.2.0.20250326 typeshed_client 2.7.0 typing_extensions 4.13.2 tzdata 2025.2 urllib3 2.4.0 virtualenv 20.31.2 webencodings 0.5.1 win32_setctime 1.2.0 xarray 2025.4.0 xlrd 2.0.1 XlsxWriter 3.2.3
Beta Was this translation helpful? Give feedback.
All reactions