Pytype

Latest version: v2024.10.11

Safety actively analyzes 689550 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 34

2024.10.11

Updates:
* Drop support for Python 3.8 and 3.9.

* Make merge_pyi not to overwrite existing type annotations.

* When printing types (e.g. in error messages or `reveal_type`), print generic
builtin names in lowercase.

Old: `from typing import List; List[Foo]`
New: `list[Foo]`

Bug fixes:
* Unpin dependency on networkx, which means pytype now supports >=3.3.
* Emit all unused/duplicate files with --unused_imports_info_files option,
rather than only one per unique module name.
* Change return types of AsyncGenerator's methods to coroutines. This brings
pytype's definition in line with the definition on typeshed and reflects the
fact that asynchronous generators defined using the `async def`/`yield` syntax
have methods returning coroutines rather than just arbitrary awaitables.
* Fix type guards propagating invisibile bindings. Fixes some incorrect "used
after deleted" errors with Python 3.12.
* Fix resolution of ParamSpec in files with circular imports.

2024.09.13

Updates:
* Basic support for Python 3.12.

With this release you can run pytype with Python 3.12. But pytype has no
support for any new features added in Python 3.12.

Look out for type checking changes caused by different bytecode emit:
* dict/list/set comprehensions are type checked 1 level deeper.
* Errors after `if` statements can be printed differently.

* Add support for pickled pyi files in merge_pyi.py.

* Several performance improvements.

* Stop validating imports map. Pytype used to validate that each file in an
import map exists. This has proved too costly, especially on network file
systems. Pytype now assumes import maps specified via --imports_info are
correct.

* Add support for flag files (required for Bazel workers).

* Change the format of errors printed to the console.

Errors now also include the column number and a code snippet, which highlights
the part that's broken.

Old:
File "test.py", line 4, in foo: unsupported operand type(s) for +: str and int [unsupported-operands]
Function __add__ on str expects str
New:
test.py:4:10: error: in foo: unsupported operand type(s) for +: str and int [unsupported-operands]
Function __add__ on str expects str
print(arg + 3)
~~~~~~~

Bug fixes:
* Add type definitions for `aiter()` and `anext()`.
* Don't include deleted top-level variables in module types.
* Don't crash when a Generic subtype uses a TypeVar differently.
* Fix type inference for `iter(func, None)`.

2024.04.11

Updates:
* Change error message hint to suggest `X | None` rather than `Optional[X]`.

Bug fixes:
* Take the 'maybe_missing_members' attribute into account when setting up enum
classes.
* Fix a bug in signature compatibility checking.
* Teach main.py how to fix unescaped spaces in command-line arguments.
* Fix return type of exit() and quit().
* Update pytype_runner.py - change escape_ninja_path to escape all the ninja
path escape-needing characters
* Modify type annotations for coroutines as soon as they are created.
* Fully promote __init_subclass__ to a classmethod.

2024.03.19

Updates:
* Add 'default' field to pytd.TypeParameter.

Bug fixes:
* Raise an error when a non-class is passed to a class match case.

2024.03.11

Updates:
* Split generate_pyi into separate components for ast and pyi generation.
* Replace `pickle` with `msgspec`.
* Support PEP 742 (TypeIs).
* Update typeshed pin to commit c35b3bc from Mar 8.
* Support typing_extensions.Unpack usage in typeshed.

Bug fixes:
* Fix a corner case with an indefinite case in a match with concrete values.
* Check types as well for dataclasses.replace.
* Export enum values as Literals where possible.
* Remove mystery 'None' from overlays/named_tuple.
* Still do property lookups when maybe_missing_members is set.
* Fix crash in enum_overlay.
* Recognize __func__ attribute on methods.
* Fix a crash when constant-folding an invalid map literal.

2024.02.27

Updates:
* Add support for pragmas to pytype.
* Implement the cache-return pragma.

Bug fixes:
* Track the set of case lines we have encountered, not just the number of them.
* Fix interaction between Self and overload.
* Typo fix in cover_from_cmp.
* Add __match_args__ to dataclasses.
* Add missing __reduce__ method to builtins.object.
* Fix a bug in how we resolve aliases in pyi files.
* Don't crash when using a method as a fiddle config type constructor.

Page 1 of 34

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.