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

merge types-colorama #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jmelahman
Copy link

@jmelahman jmelahman commented Aug 7, 2023

Description

Adds types that I believe are fully compliant with PEP-561. Borrows heavily from types-colorama. Includes slight modifications to those to please stubtest and adds type stubs for colorama/tests/.

I tried my best to please stubtest, but it did not like winterm.pyi mostly being gated on sys.platform == 'win32', but that seems informative and desired, and I couldn't find a mechanism within stubtest to ignore these errors without --ignore-missing-stub hence its inclusion in tox.ini.

Closes #206

How this was tested

You can test the correctness of the stubs with,

tox -e mypy
$ tox -e mypy
...
mypy: install_package> python -I -m pip install --force-reinstall --no-deps /home/jamison/code/third_party/colorama/.tox/.tmp/package/2/colorama-0.4.7.dev1.tar.gz
mypy: commands[0]> mypy .
Success: no issues found in 13 source files
mypy: commands[1]> python -m mypy.stubtest --ignore-missing-stub colorama
Success: no issues found in 13 modules
.pkg: _exit> python /usr/lib/python3.11/site-packages/pyproject_api/_backend.py True hatchling.build
  mypy: OK (8.11=setup[6.47]+cmd[0.13,1.50] seconds)
  congratulations :) (8.16 seconds)

I tested this e2e as follows (outside of the repository),

$ python -m venv venv

$ ./venv/bin/python -m pip install mypy==1.4.1

$ ./venv/bin/python -m mypy <(echo "import colorama")
/dev/fd/63:1: error: Library stubs not installed for "colorama"  [import]
    import colorama
    ^
/dev/fd/63:1: note: Hint: "python3 -m pip install types-colorama"
/dev/fd/63:1: note: (or run "mypy --install-types" to install all missing stub packages)
/dev/fd/63:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

$ ./venv/bin/python -m pip install -e /path/to/colorama
...
Successfully installed colorama-0.4.7.dev1

$ ./venv/bin/python -m mypy <(echo "import colorama")
Success: no issues found in 1 source file

Confirmed existing compatibility,

$ tox 
...
  py27: OK (7.78=setup[7.73]+cmd[0.06] seconds)
  py37: OK (7.27=setup[7.20]+cmd[0.06] seconds)
  py38: OK (6.74=setup[6.61]+cmd[0.13] seconds)
  py39: OK (7.40=setup[7.28]+cmd[0.12] seconds)
  py310: OK (7.23=setup[7.12]+cmd[0.11] seconds)
  pypy: OK (10.44=setup[10.24]+cmd[0.21] seconds)
  pypy3: OK (11.89=setup[11.17]+cmd[0.71] seconds)
  congratulations :) (58.80 seconds)

type tests

tox

py.typed

nit
Comment on lines +3 to +9
from .initialise import (
colorama_text as colorama_text,
deinit as deinit,
init as init,
just_fix_windows_console as just_fix_windows_console,
reinit as reinit,
)
Copy link

Choose a reason for hiding this comment

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

why the as is needed?

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.

Type hints
2 participants