python-type-stubs/utils
Avasam 43650eab93 pywin32 upstreamed to typeshed 2022-10-10 13:18:43 -04:00
..
build_bundle pywin32 upstreamed to typeshed 2022-10-10 13:18:43 -04:00
README.md Create README.md 2020-08-07 09:53:05 -07:00
count_ids.py Removed uneeded imports. 2020-08-06 20:11:37 -07:00
validate_stubs.py Added utility scripts. Renamed DType to Dtype. Made the 2020-08-06 09:19:23 -07:00

README.md

Useful Utilities

This folder contains a couple of scripts that may be useful when creating stubs.

  • count_ids.py will count the occurrence of identifiers across a set of files. With --uniq it will out the IDs that occurred once only, including their location and context. This can be useful to find classes and functions in the stubs that are defined but never referenced, in cases where all top-level imports of functions/classes are explicit (i.e. where the imports are not of the form "import module as m" but of the form "from module import class as c, function as f").
  • validate_stubs.py is a basic stub validator, that looks primarily for signature mismatches and missing methods. It gathers information about overloads but does not use that yet. It is limited in use because it imports .pyi files as Python, and so is much more likely to break in the presence of circular imports, etc. But it may be worth running on your stubs. The easiest way to do so is to change into this directory in your copy of the repo and just use python validate_stubs.py <packagename>. It will then look in the root folder of the repo for the stub packages.

You can run both scripts with --help for more detailed argument help.