Skip to content

Commit fef5e21

Browse files
Zeno-soledeepin-ci-robot
authored andcommitted
feat: update python-typeguard to 2.2.2
1 parent 87f9234 commit fef5e21

File tree

20 files changed

+2077
-36
lines changed

20 files changed

+2077
-36
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.project
2+
.pydevproject
3+
.idea
4+
.tox
5+
.coverage
6+
.cache
7+
.eggs/
8+
*.egg-info/
9+
*.pyc
10+
__pycache__/
11+
docs/_build/
12+
dist/
13+
build/

.travis.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
language: python
2+
sudo: false
3+
4+
stages:
5+
- name: test
6+
- name: deploy to pypi
7+
if: type = push AND tag =~ ^\d+\.\d+\.\d+
8+
9+
jobs:
10+
fast_finish: true
11+
include:
12+
- env: TOXENV=flake8
13+
14+
- env: TOXENV=pypy3
15+
cache: pip
16+
python: pypy3
17+
18+
- env: TOXENV=py34
19+
python: "3.4"
20+
after_success: &after_success
21+
- pip install coveralls
22+
- coveralls
23+
24+
- env: TOXENV=py35
25+
python: "3.5.0"
26+
after_success: *after_success
27+
28+
- env: TOXENV=py35
29+
python: "3.5.2"
30+
after_success: *after_success
31+
32+
- env: TOXENV=py36
33+
python: "3.6"
34+
after_success: *after_success
35+
36+
- env: TOXENV=py37
37+
python: "3.7"
38+
dist: xenial
39+
sudo: required
40+
after_success: *after_success
41+
42+
- stage: deploy to pypi
43+
install: skip
44+
script: skip
45+
deploy:
46+
provider: pypi
47+
user: agronholm
48+
password:
49+
secure: gRSVobMY46ku8LMU/CkbhoawxDKZK0bQge2jBZwMt6UNK8X/Cu/mYHS7pihWRqGWacURLp7WZGeUB9ouHfGVIqlc8KQvdS4IgTHgo/CyZVG6AytyRPj+by9tmmYGh58J6DBstTD8c3h6pVytV4f0GcPJh+Cqfgfa6TKLF9dstxZELl5U4W46Po1Rk6Jk0GmhA7qKUd6/Y9fNRPntuEABFNGca8zTDinYTBzhQ6FbbuXfaF4FQkx3EvPm72ruagNkjCBkKXeqSr80Zxl0pPK5imW9VxhumnCm+DwStZ1dISQhEoJzK3b9GIllcFFWF4vUkTlEv9T+yZMhVyrJ+BBqPfKq1eNOALyWSVBTwWmjTez1AD0nNC4s5HegvKf2PF8F7y3EGUm+TLyKN3gC3LX14MHDJz4GJXY7n9gPW8syXU3npc1+bmaf1yfnR1BxncJQmru8nlmrpjG86w9qBH4BBSlkpTF7M82vcFKQ2w9BGZwoQ9vvzduMGRXCwgONfor+UPaRVarLyc+0j6HLXsC+EI9JN1PcDWF7WTj+PizYERB+U9PpjgniAKffGvhUUxjJvVnD9f/6CIKq4qjlTLv8C7PMwx1MVbE+p1JTxq530rQ55RMXicJCvhkn9mM0ytz/JUrDryOGDqmKiWVp53F+yLJHsUy8sN/zT3s6n8tf/Zg=
50+
distributions: sdist bdist_wheel
51+
on:
52+
tags: true
53+
54+
python: "3.4"
55+
56+
install: pip install tox
57+
58+
script: tox

CHANGELOG.rst

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Version history
2+
===============
3+
4+
This library adheres to `Semantic Versioning <http://semver.org/>`_.
5+
6+
**2.2.2** (2018-08-13)
7+
8+
- Fixed false positive when checking a callable against the plain ``typing.Callable`` on Python 3.7
9+
10+
**2.2.1** (2018-08-12)
11+
12+
- Argument type annotations are no longer unioned with the types of their default values, except in
13+
the case of ``None`` as the default value (although PEP 484 still recommends against this)
14+
- Fixed some generic types (``typing.Collection`` among others) producing false negatives on
15+
Python 3.7
16+
- Shortened unnecessarily long tracebacks by raising a new ``TypeError`` based on the old one
17+
- Allowed type checking against arbitrary types by removing the requirement to supply a call memo
18+
to ``check_type()``
19+
- Fixed ``AttributeError`` when running with the pydev debugger extension installed
20+
- Fixed getting type names on ``typing.*`` on Python 3.7 (fix by Dale Jung)
21+
22+
**2.2.0** (2018-07-08)
23+
24+
- Fixed compatibility with Python 3.7
25+
- Removed support for Python 3.3
26+
- Added support for ``typing.NewType`` (contributed by reinhrst)
27+
28+
**2.1.4** (2018-01-07)
29+
30+
- Removed support for backports.typing, as it has been removed from PyPI
31+
- Fixed checking of the numeric tower (complex -> float -> int) according to PEP 484
32+
33+
**2.1.3** (2017-03-13)
34+
35+
- Fixed type checks against generic classes
36+
37+
**2.1.2** (2017-03-12)
38+
39+
- Fixed leak of function objects (should've used a ``WeakValueDictionary`` instead of
40+
``WeakKeyDictionary``)
41+
- Fixed obscure failure of TypeChecker when it's unable to find the function object
42+
- Fixed parametrized ``Type`` not working with type variables
43+
- Fixed type checks against variable positional and keyword arguments
44+
45+
**2.1.1** (2016-12-20)
46+
47+
- Fixed formatting of README.rst so it renders properly on PyPI
48+
49+
**2.1.0** (2016-12-17)
50+
51+
- Added support for ``typings.Type`` (available in Python 3.5.2+)
52+
- Added a third, ``sys.setprofile()`` based type checking approach (``typeguard.TypeChecker``)
53+
- Changed certain type error messages to display "function" instead of the function's qualified
54+
name
55+
56+
**2.0.2** (2016-12-17)
57+
58+
- More Python 3.6 compatibility fixes (along with a broader test suite)
59+
60+
**2.0.1** (2016-12-10)
61+
62+
- Fixed additional Python 3.6 compatibility issues
63+
64+
**2.0.0** (2016-12-10)
65+
66+
- **BACKWARD INCOMPATIBLE** Dropped Python 3.2 support
67+
- Fixed incompatibility with Python 3.6
68+
- Use ``inspect.signature()`` in place of ``inspect.getfullargspec``
69+
- Added support for ``typing.NamedTuple``
70+
71+
**1.2.3** (2016-09-13)
72+
73+
- Fixed ``@typechecked`` skipping the check of return value type when the type annotation was
74+
``None``
75+
76+
**1.2.2** (2016-08-23)
77+
78+
- Fixed checking of homogenous Tuple declarations (``Tuple[bool, ...]``)
79+
80+
**1.2.1** (2016-06-29)
81+
82+
- Use ``backports.typing`` when possible to get new features on older Pythons
83+
- Fixed incompatibility with Python 3.5.2
84+
85+
**1.2.0** (2016-05-21)
86+
87+
- Fixed argument counting when a class is checked against a Callable specification
88+
- Fixed argument counting when a functools.partial object is checked against a Callable
89+
specification
90+
- Added checks against mandatory keyword-only arguments when checking against a Callable
91+
specification
92+
93+
**1.1.3** (2016-05-09)
94+
95+
- Gracefully exit if ``check_type_arguments`` can't find a reference to the current function
96+
97+
**1.1.2** (2016-05-08)
98+
99+
- Fixed TypeError when checking a builtin function against a parametrized Callable
100+
101+
**1.1.1** (2016-01-03)
102+
103+
- Fixed improper argument counting with bound methods when typechecking callables
104+
105+
**1.1.0** (2016-01-02)
106+
107+
- Eliminated the need to pass a reference to the currently executing function to
108+
``check_argument_types()``
109+
110+
**1.0.2** (2016-01-02)
111+
112+
- Fixed types of default argument values not being considered as valid for the argument
113+
114+
**1.0.1** (2016-01-01)
115+
116+
- Fixed type hints retrieval being done for the wrong callable in cases where the callable was
117+
wrapped with one or more decorators
118+
119+
**1.0.0** (2015-12-28)
120+
121+
- Initial release

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
2+
3+
Copyright (c) Alex Grönholm
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+
software and associated documentation files (the "Software"), to deal in the Software
7+
without restriction, including without limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
9+
to whom the Software is furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all copies or
12+
substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.rst

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
.. image:: https://travis-ci.org/agronholm/typeguard.svg?branch=master
2+
:target: https://travis-ci.org/agronholm/typeguard
3+
:alt: Build Status
4+
.. image:: https://coveralls.io/repos/agronholm/typeguard/badge.svg?branch=master&service=github
5+
:target: https://coveralls.io/github/agronholm/typeguard?branch=master
6+
:alt: Code Coverage
7+
8+
This library provides run-time type checking for functions defined with argument type annotations.
9+
10+
The ``typing`` module introduced in Python 3.5 (and available on PyPI for older versions of
11+
Python 3) is supported. See below for details.
12+
13+
There are three principal ways to use type checking, each with its pros and cons:
14+
15+
#. calling ``check_argument_types()`` from within the function body:
16+
17+
* debugger friendly (except when running with the pydev debugger with the C extension installed)
18+
* cannot check the type of the return value
19+
* does not work reliably with dynamically defined type hints (e.g. in nested functions)
20+
#. decorating the function with ``@typechecked``:
21+
22+
* 100% reliable at finding the function object to be checked (does not need to check the garbage
23+
collector)
24+
* can check the type of the return value
25+
* adds an extra frame to the call stack for every call to a decorated function
26+
#. using ``with TypeChecker('packagename'):``:
27+
28+
* emits warnings instead of raising ``TypeError``
29+
* eliminates boilerplate
30+
* multiple TypeCheckers can be stacked/nested
31+
* noninvasive (only records type violations; does not raise exceptions)
32+
* does not work reliably with dynamically defined type hints (e.g. in nested functions)
33+
* may cause problems with badly behaving debuggers or profilers
34+
35+
If a function is called with incompatible argument types or a ``@typechecked`` decorated function
36+
returns a value incompatible with the declared type, a descriptive ``TypeError`` exception is
37+
raised.
38+
39+
Type checks can be fairly expensive so it is recommended to run Python in "optimized" mode
40+
(``python -O`` or setting the ``PYTHONOPTIMIZE`` environment variable) when running code containing
41+
type checks in production. The optimized mode will disable the type checks, by virtue of removing
42+
all ``assert`` statements and setting the ``__debug__`` constant to ``False``.
43+
44+
Using ``check_argument_types()``:
45+
46+
.. code-block:: python3
47+
48+
from typeguard import check_argument_types
49+
50+
def some_function(a: int, b: float, c: str, *args: str):
51+
assert check_argument_types()
52+
...
53+
54+
Using ``@typechecked``:
55+
56+
.. code-block:: python3
57+
58+
from typeguard import typechecked
59+
60+
@typechecked
61+
def some_function(a: int, b: float, c: str, *args: str) -> bool:
62+
...
63+
64+
To enable type checks even in optimized mode:
65+
66+
.. code-block:: python3
67+
68+
@typechecked(always=True)
69+
def foo(a: str, b: int, c: Union[str, int]) -> bool:
70+
...
71+
72+
Using ``TypeChecker``:
73+
74+
.. code-block:: python3
75+
76+
from warnings import filterwarnings
77+
78+
from typeguard import TypeChecker, TypeWarning
79+
80+
# Display all TypeWarnings, not just the first one
81+
filterwarnings('always', category=TypeWarning)
82+
83+
# Run your entire application inside this context block
84+
with TypeChecker(['mypackage', 'otherpackage']):
85+
mypackage.run_app()
86+
87+
# Alternatively, manually start (and stop) the checker:
88+
checker = TypeChecker('mypackage')
89+
checker.start()
90+
mypackage.start_app()
91+
92+
.. hint:: Some other things you can do with ``TypeChecker``:
93+
94+
* display all warnings from the start with ``python -W always::typeguard.TypeWarning``
95+
* redirect them to logging using ``logging.captureWarnings()``
96+
* record warnings in your pytest test suite and fail test(s) if you get any
97+
(see the `pytest documentation <http://doc.pytest.org/en/latest/recwarn.html>`_ about that)
98+
99+
To directly check a value against the specified type:
100+
101+
.. code-block:: python3
102+
103+
from typeguard import check_type
104+
105+
check_type('variablename', [1234], List[int])
106+
107+
108+
The following types from the ``typing`` package have specialized support:
109+
110+
============== ============================================================
111+
Type Notes
112+
============== ============================================================
113+
``Callable`` Argument count is checked but types are not (yet)
114+
``Dict`` Keys and values are typechecked
115+
``List`` Contents are typechecked
116+
``NamedTuple`` Field values are typechecked
117+
``Set`` Contents are typechecked
118+
``Tuple`` Contents are typechecked
119+
``Type``
120+
``TypeVar`` Constraints, bound types and co/contravariance are supported
121+
but custom generic types are not (due to type erasure)
122+
``Union``
123+
============== ============================================================
124+
125+
126+
Project links
127+
-------------
128+
129+
* `Change log <https://github.com/agronholm/typeguard/blob/master/CHANGELOG.rst>`_
130+
* `Source repository <https://github.com/agronholm/typeguard>`_
131+
* `Issue tracker <https://github.com/agronholm/typeguard/issues>`_

debian/changelog

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
template-repository (1.0-1) unstable; urgency=medium
1+
python-typeguard (2.2.2-2) unstable; urgency=medium
22

3-
* Initial release
3+
* debian/control
4+
- point VCS to the new location for DPT
5+
- update team name and email address
46

5-
-- Tsic404 <[email protected]> Sat, 28 Jan 2023 13:46:49 +0800
7+
-- Sandro Tosi <[email protected]> Thu, 09 Jun 2022 14:23:48 -0400
8+
9+
python-typeguard (2.2.2-1) unstable; urgency=medium
10+
11+
[ Joel Cross ]
12+
* Upgrade upstream to 2.2.2
13+
* Bump standards-version and debhelper-compat
14+
15+
[ Sergio Durigan Junior ]
16+
* Run "dh_auto_clean" with LC_ALL=C.UTF-8.
17+
This is necessary because the author's name contains a special
18+
character in "setup.cfg", which causes an error when running "python3
19+
setup.py clean".
20+
21+
-- Joel Cross <[email protected]> Mon, 21 Jan 2019 23:18:27 +0000
22+
23+
python-typeguard (2.1.4-1) unstable; urgency=medium
24+
25+
* Initial release (Closes: #897419)
26+
27+
-- Joel Cross <[email protected]> Wed, 02 May 2018 11:17:21 +0100

debian/compat

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)