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 typing and py.typed #71

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,14 @@ jobs:
name: html-report
path: htmlcov
if: ${{ failure() }}

typing:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip install tox
- run: tox -e typing
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#
alabaster==0.7.13
# via sphinx
babel==2.12.1
babel==2.13.1
# via sphinx
certifi==2024.7.4
# via requests
charset-normalizer==3.3.0
charset-normalizer==3.3.2
# via requests
docutils==0.17.1
# via
Expand Down
1 change: 0 additions & 1 deletion requirements-tests37.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ pytest<7
pytest-cov
coverage[toml]<6
importlib_metadata; python_version < '3.8'
pytest-benchmark
7 changes: 1 addition & 6 deletions requirements-tests37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,16 @@ importlib-metadata==6.7.0 ; python_version < "3.8"
# pytest
iniconfig==2.0.0
# via pytest
packaging==23.2
packaging==23.1
# via pytest
pluggy==1.2.0
# via pytest
py==1.11.0
# via pytest
py-cpuinfo==9.0.0
# via pytest-benchmark
pytest==6.2.5
# via
# -r requirements-tests37.in
# pytest-benchmark
# pytest-cov
pytest-benchmark==4.0.0
# via -r requirements-tests37.in
pytest-cov==4.1.0
# via -r requirements-tests37.in
toml==0.10.2
Expand Down
1 change: 1 addition & 0 deletions requirements-tests39.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ pylint>=2.15
astroid>=2.11
wrapt>=1.14
pytest-benchmark
mypy
14 changes: 10 additions & 4 deletions requirements-tests39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ astroid==3.0.1
# pylint
autopep8==2.0.4
# via -r requirements-tests39.in
charset-normalizer==3.3.0
charset-normalizer==3.3.2
# via docformatter
coverage==7.3.2
# via pytest-cov
Expand Down Expand Up @@ -38,6 +38,10 @@ mccabe==0.7.0
# via
# flake8
# pylint
mypy==1.6.1
# via -r requirements-tests39.in
mypy-extensions==1.0.0
# via mypy
packaging==23.2
# via pytest
pbr==5.11.1
Expand All @@ -60,9 +64,9 @@ pygments==2.16.1
# via
# -r requirements-tests39.in
# doc8
pylint==3.0.1
pylint==3.0.2
# via -r requirements-tests39.in
pytest==7.4.2
pytest==7.4.3
# via
# -r requirements-tests39.in
# pytest-benchmark
Expand All @@ -84,13 +88,15 @@ tomli==2.0.1
# autopep8
# coverage
# doc8
# mypy
# pylint
# pytest
tomlkit==0.12.1
tomlkit==0.12.2
# via pylint
typing-extensions==4.8.0
# via
# astroid
# mypy
# pylint
untokenize==0.1.1
# via docformatter
Expand Down
2 changes: 1 addition & 1 deletion requirements-update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
certifi==2023.7.22
# via requests
charset-normalizer==3.3.0
charset-normalizer==3.3.2
# via requests
idna==3.4
# via requests
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def main():
url='https://github.com/jquast/wcwidth',
package_data={
'': ['LICENSE', '*.rst'],
'wcwidth': ['py.typed', '*.pyi'],
},
zip_safe=True,
classifiers=[
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,10 @@ basepython = python{env:TOXPYTHON:{env:TRAVIS_PYTHON_VERSION:3.10}}
passenv = TOXENV,CI,TRAVIS,TRAVIS_*,CODECOV_*
deps = codecov
commands = codecov -e TOXENV

[testenv:typing]
basepython = python3.12
deps = mypy
commands =
stubtest wcwidth

14 changes: 5 additions & 9 deletions wcwidth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@
# any future version.

# local
from .wcwidth import ZERO_WIDTH # noqa
from .wcwidth import (WIDE_EASTASIAN,
VS16_NARROW_TO_WIDE,
wcwidth,
wcswidth,
_bisearch,
list_versions,
_wcmatch_version,
_wcversion_value)
from .unicode_versions import list_versions
from .table_zero import ZERO_WIDTH # noqa
from .table_wide import WIDE_EASTASIAN # noqa
from .table_vs16 import VS16_NARROW_TO_WIDE # noqa
from .wcwidth import wcwidth, wcswidth, _bisearch, _wcmatch_version, _wcversion_value

# The __all__ attribute defines the items exported from statement,
# 'from wcwidth import *', but also to say, "This is the public API".
Expand Down
Empty file added wcwidth/py.typed
Empty file.
2 changes: 1 addition & 1 deletion wcwidth/unicode_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def list_versions():
``unicode_version`` to the ``wcwidth()`` family of functions.

:returns: Supported Unicode version numbers in ascending sorted order.
:rtype: list[str]
:rtype: tuple[str, ...]
"""
return (
"4.1.0",
Expand Down
2 changes: 2 additions & 0 deletions wcwidth/unicode_versions.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def list_versions() -> tuple[str, ...]:
...
32 changes: 32 additions & 0 deletions wcwidth/wcwidth.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from typing import Optional, AnyStr

import sys

if sys.version_info >= (3,):
def wcwidth(wc: str, unicode_version: str = ...) -> int:
...


def wcswidth(pwcs: str, n: Optional[int] = None, unicode_version: str = ...):
...
else:
def wcwidth(wc: AnyStr, unicode_version: str = ...) -> int:
...


def wcswidth(pwcs: AnyStr, n: Optional[int] = None, unicode_version: str = ...):
...




def _bisearch(ucs: int, table: list[tuple[int, int]]) -> int:
...


def _wcversion_value(ver_string: str) -> tuple[int, ...]:
...


def _wcmatch_version(given_version: str) -> str:
...
Loading