A static type analyzer for Python code

Overview

CI PyPI - Wheel

pytype - ?

Pytype checks and infers types for your Python code - without requiring type annotations. Pytype can:

  • Lint plain Python code, flagging common mistakes such as misspelled attribute names, incorrect function calls, and much more, even across file boundaries.
  • Enforce user-provided type annotations. While annotations are optional for pytype, it will check and apply them where present.
  • Generate type annotations in standalone files ("pyi files"), which can be merged back into the Python source with a provided merge-pyi tool.

Pytype is a static analyzer; it does not execute the code it runs on.

Thousands of projects at Google rely on pytype to keep their Python code well-typed and error-free.

For more information, check out the user guide, FAQ, or supported features.

How is pytype different from other type checkers?

  1. Pytype uses inference instead of gradual typing. This means it will infer types on code even when the code has no type hints on it. So it can detect issues with code like this, which other type checkers would miss:

    def f():
        return "PyCon"
    def g():
        return f() + 2019
    
    # pytype: line 4, in g: unsupported operand type(s) for +: 'str'
    # and 'int' [unsupported-operands]
  2. Pytype is lenient instead of strict. That means it allows all operations that succeed at runtime and don't contradict annotations. For instance, this code will pass as safe in pytype, but fail in other type checkers, which assign types to variables as soon as they are initialized:

    from typing import List
    def get_list() -> List[str]:
        lst = ["PyCon"]
        lst.append(2019)
        return [str(x) for x in lst]
    
    # mypy: line 4: error: Argument 1 to "append" of "list" has
    # incompatible type "int"; expected "str"

Also see the corresponding FAQ entry.

Quickstart

To quickly get started with type-checking a file or directory, run the following, replacing file_or_directory with your input:

pip install pytype
pytype file_or_directory

To set up pytype on an entire package, add the following to a setup.cfg file in the directory immediately above the package, replacing package_name with the package name:

[pytype]
inputs = package_name

Now you can run the no-argument command pytype to type-check the package. It's also easy to add pytype to your automated testing; see this example of a GitHub project that runs pytype on Travis.

Finally, pytype generates files of inferred type information, located by default in .pytype/pyi. You can use this information to type-annotate the corresponding source file:

merge-pyi -i <filepath>.py .pytype/pyi/<filename>.pyi

Requirements

You need a Python 3.6-3.8 interpreter to run pytype, as well as an interpreter in $PATH for the Python version of the code you're analyzing (supported: 2.7, 3.5-3.8).

Platform support:

  • Pytype is currently developed and tested on Linux*, which is the main supported platform.
  • Installation on MacOSX requires OSX 10.7 or higher and Xcode v8 or higher.
  • Windows is currently not supported unless you use WSL.

* Note: On Alpine Linux, installing may fail due to issues with upstream dependencies. See the details of this issue for a possible fix.

Installing

Pytype can be installed via pip. Note that the installation requires wheel and setuptools. (If you're working in a virtualenv, these two packages should already be present.)

pip install pytype

Or from the source code on GitHub.

git clone --recurse-submodules https://github.com/google/pytype.git
cd pytype
pip install .

Instead of using --recurse-submodules, you could also have run

git submodule init
git submodule update

in the pytype directory. To edit the code and have your edits tracked live, replace the pip install command with:

pip install -e .

Installing on WSL

Follow the steps above, but make sure you have the correct libraries first:

sudo apt install build-essential python3-dev libpython3-dev

Usage

usage: pytype [options] input [input ...]

positional arguments:
  input                 file or directory to process

Common options:

  • -V, --python-version: Python version (major.minor) of the target code. Defaults to the version that pytype is running under.
  • -o, --output: The directory into which all pytype output goes, including generated .pyi files. Defaults to .pytype.
  • -d, --disable. Comma or space separated list of error names to ignore. Detailed explanations of pytype's error names are in this doc. Defaults to empty.

For a full list of options, run pytype --help.

In addition to the above, you can direct pytype to use a custom typeshed installation instead of its own bundled copy by setting $TYPESHED_HOME.

Config File

For convenience, you can save your pytype configuration in a file. The config file is an INI-style file with a [pytype] section; if an explicit config file is not supplied, pytype will look for a [pytype] section in the first setup.cfg file found by walking upwards from the current working directory.

Start off by generating a sample config file:

$ pytype --generate-config pytype.cfg

Now customize the file based on your local setup, keeping only the sections you need. Directories may be relative to the location of the config file, which is useful if you want to check in the config file as part of your project.

For example, suppose you have the following directory structure and want to analyze package ~/repo1/foo, which depends on package ~/repo2/bar:

~/
├── repo1
│   └── foo
│       ├── __init__.py
│       └── file_to_check.py
└── repo2
    └── bar
        ├── __init__.py
        └── dependency.py

Here is the filled-in config file, which instructs pytype to type-check ~/repo1/foo as Python 3.6 code, look for packages in ~/repo1 and ~/repo2, and ignore attribute errors. Notice that the path to a package does not include the package itself.

$ cat ~/repo1/pytype.cfg

# NOTE: All relative paths are relative to the location of this file.

[pytype]

# Space-separated list of files or directories to process.
inputs =
    foo

# Python version (major.minor) of the target code.
python_version = 3.6

# Paths to source code directories, separated by ':'.
pythonpath =
    .:
    ~/repo2

# Comma or space separated list of error names to ignore.
disable =
    attribute-error

We could've discovered that ~/repo2 needed to be added to the pythonpath by running pytype's broken dependency checker:

$ pytype --config=~/repo1/pytype.cfg ~/repo1/foo/*.py --unresolved

Unresolved dependencies:
  bar.dependency

Subtools

Pytype ships with a few scripts in addition to pytype itself:

  • annotate-ast, an in-progress type annotator for ASTs.
  • merge-pyi, for merging type information from a .pyi file into a Python file.
  • pytd-tool, a parser for .pyi files.
  • pytype-single, a debugging tool for pytype developers, which analyzes a single Python file assuming that .pyi files have already been generated for all of its dependencies.
  • pyxref, a cross references generator.

2021 Roadmap

  • Python 3.9 support
  • Better performance on large files
  • Support for numerical libraries

License

Apache 2.0

Disclaimer

This is not an official Google product.

Issues
  • Python 3 support?

    Python 3 support?

    I'm attempting to use pytype and it appears it doesn't support Python 3( complains about no StringIO module). Any plans to support Python 3? or, perhaps add some documentation about which version of Python are supported.

    opened by jrenner 32
  • xref crashes with AttributeError: 'LateAnnotation' object has no attribute 'Bindings'

    xref crashes with AttributeError: 'LateAnnotation' object has no attribute 'Bindings'

    Clone https://github.com/kamahen/pykythe.git I don't think you need to install other the other pre-reqs to regenerate this bug; just run:

    make pytype
    

    You should see these lines in the output:

    pykythe/ast_cooked.py pytype_output/imports/pykythe.ast_cooked.imports /tmp/ast_cooked.xref.json
    Pytype error: AttributeError: 'LateAnnotation' object has no attribute 'Bindings'
    
    bug 
    opened by kamahen 22
  • Generating pyis in the right order is cumbersome

    Generating pyis in the right order is cumbersome

    I just see this kind of declaration being generated:

      def to_dataframe(self, ...) -> Any: ...
      def to_file(self, path, ...) -> Any: ...
      def to_view(self, view_name) -> Any: ...
    

    I..e. with optional args it just generates '...' and with positional args it just outputs the arg name, and the return types are just Any. This seems to be so generic as to not be useful at all. What am I missing here?

    I'm just running this like:

    pytype foo.py -o foo.pyi
    
    opened by gramster 20
  • Pytype fails on MacOSX(Mojave-10.14.9) when inferring types.

    Pytype fails on MacOSX(Mojave-10.14.9) when inferring types.

    Hello,

    I am trying to execute Pytype in a project as below.

    pytype --pythonpath=./$PROJECT_DIRECTORY --no-report-errors $PROJECT_DIRECTORY

    What I need is to run Pytype over a project (first step) and then use AST annotator to get type information of variables in a file. When I run above command it gives me the following error.

    [2/154] infer pymc3.backends.HDF5
    FAILED: /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi 
    /Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/bin/python -m pytype.single --imports_info /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/imports/pymc3.backends.HDF5.imports --module-name pymc3.backends.HDF5 -V 3.7 -o /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi --no-report-errors --nofail --quick /Users/user_name/Documents/Research_Topic_2/PytypeTest/pymc3-master/pymc3/backends/HDF5.py
    ERROR:pytype.imports_map_loader Invalid imports_map entries (checking from root dir: /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype)
    ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi' (mapped from 'pymc3/backends/HDF5')
    ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/NDArray.pyi' (mapped from 'pymc3/backends/NDArray')
    ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/SQLite.pyi' (mapped from 'pymc3/backends/SQLite')
    ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/Text.pyi' (mapped from 'pymc3/backends/Text')
    ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/__init__.pyi' (mapped from 'pymc3/backends/__init__')
    ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/base.pyi' (mapped from 'pymc3/backends/base')
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/single.py", line 103, in <module>
        sys.exit(main() or 0)
      File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/single.py", line 66, in main
        options = config.Options(sys.argv[1:])
      File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/config.py", line 54, in __init__
        Postprocessor(names, options, self).process()
      File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/config.py", line 392, in process
        node.processor(value)
      File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/config.py", line 550, in _store_imports_map
        imports_map, self.output_options.output)
      File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/imports_map_loader.py", line 90, in build_imports_map
        raise ValueError(msg)
    ValueError: Invalid imports_map: /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/imports/pymc3.backends.HDF5.imports
    Bad entries:
      pymc3/backends/HDF5 -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi
      pymc3/backends/NDArray -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/NDArray.pyi
      pymc3/backends/SQLite -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/SQLite.pyi
      pymc3/backends/Text -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/Text.pyi
      pymc3/backends/__init__ -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/__init__.pyi
      pymc3/backends/base -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/base.pyi
    

    Steps to reproduce

    1. Clone https://github.com/pymc-devs/pymc3
    2. Run pytype --pythonpath=./$PROJECT_DIRECTORY --no-report-errors $PROJECT_DIRECTORY (Pytype version = 2020.08.17, OS version = macOS Mojave-10.14.9)

    Questions

    1. Do you have any idea on the above error?
    2. Suppose that, I want to run Pytype without failing. I observed two options (--nofail and --return-success) in the configuration file . When I try to run pytype with these two options, pytype does not identify the options. It says pytype: error: unrecognized arguments: --nofail. What could be the reason for these errors and what options should I use to run Pytype without failing?

    The command that I tried is pytype --pythonpath=$PROJECT_DIRECTORY --no-report-errors --nofail $PROJECT_DIRECTORY Thank you in advance.

    bug help wanted cat: infrastructure 
    opened by maldil 19
  • pytype chokes on python 3 testtools

    pytype chokes on python 3 testtools

    pytype seems to choke on testtools:

    $ cat testtools-bug.py
    #!/usr/bin/python3
    import testtools
    $ pytype -V3.5 testtools-bug.py
    CRITICAL Cannot parse input files:
    invalid syntax (_compat2x.py, line 16)
    

    It seems that pytype isn't understanding that importing compat2x is wrapped in a try: block in testtools/compat.py to determine whether it should import the python 2 or 3 version:

    try:
        from testtools import _compat2x as _compat
    except SyntaxError:
        from testtools import _compat3x as _compat
    
    opened by lantz 14
  • No such file or directory: 'ninja'

    No such file or directory: 'ninja'

    Running pytype on a Python scripts gives me the following error message.

    Computing dependencies
    Analyzing 1 sources with 2 local dependencies
    Traceback (most recent call last):
      File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/workdir/user/chdu/side_projects/dbay/.venv/lib/python3.8/site-packages/pytype/__main__.py", line 10, in <module>
        sys.exit(main())
      File "/workdir/user/chdu/side_projects/dbay/.venv/lib/python3.8/site-packages/pytype/tools/analyze_project/main.py", line 97, in main
        return runner.run()
      File "/workdir/user/chdu/side_projects/dbay/.venv/lib/python3.8/site-packages/pytype/tools/analyze_project/pytype_runner.py", line 355, in run
        ret = self.build()
      File "/workdir/user/chdu/side_projects/dbay/.venv/lib/python3.8/site-packages/pytype/tools/analyze_project/pytype_runner.py", line 346, in build
        return subprocess.call(command)
      File "/usr/lib/python3.8/subprocess.py", line 340, in call
        with Popen(*popenargs, **kwargs) as p:
      File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'ninja'
    
    opened by dclong 13
  • Question: merge two `pyi` files

    Question: merge two `pyi` files

    Hello, found existing of merge_pyi tool for merging pyi types into py files.

    Use case:

    I want to merge two pyi files. Purpose is generating stubs for code i.e. via mypy.stubgen and next apply some clarifications for types from external file. Add doc strings, clarify return parameters manually and so on.

    My use case is support stub package for some external lib. And when API is changed during release just regenerate stubs, but save all previously collected type knowledge. In this case we can automate entire process of generating and testing stubs correctness (i.e. via mypy.stubtest).

    Question:

    Are there any tools for merging exactly pyi files? Or there is only one way is parse pyi manually and manipulating parse tree from script?

    Thanks in advance!

    opened by mrkeuz 12
  • Dict[slice, ...] is not valid

    Dict[slice, ...] is not valid

    I have a function like this:

    def foo(a):
        return a[:10].lower()
    

    The generated stub is:

    def foo(a: bytes or str or unicode or Dict[slice, bytearray or bytes or str or unicode or List[?, ...] or Tuple[?, ...]]) -> bytearray or bytes or str or unicode
    

    Now, it's cute that it figures out that if the argument were a dict with slice keys and string values it might work, but in fact slice does not implement hash() so Dict[slice, ...] is nonsense.

    I'm also unclear on why it thinks that the value could be a List or Tuple, since neither of those has a lower() method.

    opened by gvanrossum 12
  • fix: simplifiy pybind11 usage

    fix: simplifiy pybind11 usage

    This is a suggestion for using pybind11 via submodule. pyproject.toml is more elegant, but does require Pip 10+. I can switch to that if requested. Follow up on #714. I don't know all the details of building from scratch (It wants bison 3), but this should be close, I think. CC @rwgk .

    I did not include ParallelCompile, but that might also be useful, I think.

    opened by henryiii 11
  • Support Python 3.8

    Support Python 3.8

    Invoking pytype under Python 3.8 fails with the following error:

    Python versions > 3.7 are not yet supported.
    

    Is there an ETA for Python 3.8 support?

    enhancement 
    opened by cjolowicz 11
  • Support for dataclasses

    Support for dataclasses

    Currently, when using python 3.7 dataclass, pytype will fail to recognize constructor arguments. Here's a proof of concept code snippet:

    from dataclasses import dataclass
    
    
    @dataclass
    class DataClass:
        first: int
        second: int
    
    
    data_class = DataClass(1, 2)
    

    It gives an error of

    File "type_check.py", line 11, in <module>: Function DataClass.__init__ expects 1 arg(s), got 3 [wrong-arg-count]
      Expected: (self)
      Actually passed: (self, _, _)
    
    enhancement 
    opened by zli117 11
  • Question: Is it okay to commit .pytype directory to repository?

    Question: Is it okay to commit .pytype directory to repository?

    Hey there, Pytypy is an amazing tool that helps me to find a lot of bugs in my sources.

    Could I commit .pytype directory to speed up checks? How pytype invalidate removed files?

    Looking forward for your answers!

    opened by mangin 0
  • Functions taking in subset TypedDicts

    Functions taking in subset TypedDicts

    I have two TypedDicts. They share the same fields, except the second one has a few extra fields. I want to create a function that works on the former, that I can call with the latter.

    Is there a way to make something like the following work?

    import typing
    
    class Parent(typing.TypedDict):
      a: typing.Text
    
    class Child(typing.TypedDict):
      a: typing.Text
      b: typing.Text
    
    def baz(foo: Parent) -> int:
      return 0
    
    x: Child = {'a': 'hello', 'b': 'world'}
    baz(x)
    

    This currently fails with the following:

    Function baz was called with the wrong arguments [wrong-arg-types]                
             Expected: (foo: Parent)                                                                                                                           
      Actually passed: (foo: Child)         
                                                                                
      TypedDict extra keys: b
    

    Having this functionality would be very useful for creating polymorphic abstract functions that can plug into a bunch of different data structures

    opened by theahura 0
  • unsupported-operands false negative for Enum or object comparison

    unsupported-operands false negative for Enum or object comparison

    Example Code

    from enum import Enum
    
    class LogLevel(Enum):
        INFO = 0
        WARN = 1
    
    if LogLevel.INFO < LogLevel.WARN:
        print("'INFO' is less than 'WARN'")
    
    if object() < object():
        print("'object()' is less than 'object()'")
    

    Both comparisons raise TypeError at runtime.

    Expected Behavior

    pytype would report an unsupported-operands error for lines 7 (Types 'LogLevel' and 'LogLevel' are not comparable) and 10 (Types 'object' and 'object' are not comparable).

    Actual Behavior

    $ pytype-single --use-enum-overlay repr.py
    $ echo $?
    0
    

    Software Versions

    Python 3.10.2 pytype 2022.06.30

    opened by Cebtenzzre 0
  • Empty list typed as List[nothing] in generated stub file

    Empty list typed as List[nothing] in generated stub file

    Example Code

    a.py

    x = []
    

    b.py

    from a import x
    

    Expected Behavior

    pytype can generate a stub file for a.py that mypy is able to successfully read. It could represent x as e.g. List[object] or List[Any].

    Actual Behavior

    $ mkdir stubs
    $ pytype-single a.py -o stubs/a.pyi
    $ MYPYPATH=stubs mypy b.py
    stubs/a.pyi:3: error: Name "nothing" is not defined
    Found 1 error in 1 file (checked 1 source file)
    

    This is the generated a.pyi:

    from typing import List
    
    x: List[nothing]
    

    Software Versions

    Python 3.10.2 pytype 2022.06.30 mypy 0.961

    opened by Cebtenzzre 0
  • xref tool ignores PYTHONPATH and doesn't create /kythe/edge/ref/imports for local imports

    xref tool ignores PYTHONPATH and doesn't create /kythe/edge/ref/imports for local imports

    I set PYTHONPATH to:

    [email protected]:~/pytype$ env | grep PYTHONPATH
    PYTHONPATH=/home/kalaskow/pytype
    

    Then I tried to generate kythe entries for pytype/tracer_vm.py file using the following command:

    [email protected]:~/pytype$ ./build/bin/xref pytype/tracer_vm.py  > entries
    

    It turns out that for import available in the system like:

    import logging
    

    there is a corresponding entry in entries:

    {"source": {"signature": "@139:147", "path": "pytype/tracer_vm.py", "language": "python", "root": "", "corpus": ""}, "edge_kind": "/kythe/edge/ref/imports", "target": {"signature": "module.Sequence", "path": "pytd:typing", "language": "python", "root": "", "corpus": "pystdlib"}, "fact_name": "/"}
    
    

    Unfortunately, for local import like:

    from pytype import special_builtins
    

    there is no entry generated in entries.

    Shouldn't we add in pytype/tools/xref/parse_args.py infrastructure options:

    def make_parser():
      # cut
      wrapper = datatypes.ParserWrapper(parser)
      pytype_config.add_basic_options(wrapper)
      pytype_config.add_infrastructure_options(wrapper)
    

    in order to provide a way for a user to specify --pythonpath to generate entries for local imports?

    bug cat: tools 
    opened by billkozbi 2
  • Windows support

    Windows support

    I tried to add windows support for pytype. It seems to work now. The package installed with pip install -e . works fine now. At least my needs has been satisfied.

    Changes

    • Replace delegate initializers with ordinary ones.
    • Update pybind11 to v2.9.0. Previous version of pybind11 causes compiler errors on msvc ( https://github.com/pybind/pybind11/issues/3477).
    • Add tools/path_tools.py. It provides functions with the same signatures as thoes defined in os.path and glob, but they replace the \ in return value with / if pytype is running on Windows.
    • Add tools/tempfile.py. Files created by NamedTemporaryFile cannot be opened twice in the same process on Windows if by default. tools/tempfile.py provides an alternative NamedTemporaryFile implementation for Windows. See https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file for details.
    • Edit several CMakeLists.txts

    Current Issue

    I ran pip install -e . && python build_scripts/run_tests.py to test it. It passed every test cases before following text showed in the command line. It seems there are some problems with the build system. (But building with pip install -e . works fine.)

    >>> Found Ninja target failures (includes test failures):
        - pytype/typegraph/cfg.so pytype/typegraph/cfg.lib
    >>> FAILED: Ninja command 'ninja -k 100000 test_all'.
    >>>         Run it in the 'out' directory to reproduce.
    >>>         Full Ninja output is available in 'C:\Users\wweih\Documents\pytype-modified\pytype\out\ninja.log'.
    >>>         Failing test modules (if any) will be reported below.
    

    ninja.log

    Help Wanted

    • I am not expertize in building systems. Are there any advice about the above issue?
    • Which tool should I use in order to format the source code?
    • / and \ are both valid seperators on Windows. It caused a lot of problems for pytype. I tried to solve this by replacing all \ with / on windows. Is this an acceptable solution?
    • Is there any automated test pipline to test my commits on Linux and macOS? Or should I setup an Linux system to test it on myself?
    opened by wayhowang 9
Owner
Google
Google ❤️ Open Source
Google
Static type checker for Python

Static type checker for Python Speed Pyright is a fast type checker meant for large Python source bases. It can run in a “watch” mode and performs fas

Microsoft 8.2k Jul 15, 2022
Robocop is a tool that performs static code analysis of Robot Framework code.

Robocop Introduction Documentation Values Requirements Installation Usage Example Robotidy FAQ Watch our talk from RoboCon 2021 about Robocop and Robo

marketsquare 120 Jun 29, 2022
CodeAnalysis - Static Code Analysis: a code comprehensive analysis platform

TCA, Tencent Cloud Code Analysis English | 简体中文 What is TCA Tencent Cloud Code A

Tencent 1.2k Jul 10, 2022
A simple stopwatch for measuring code performance with static typing.

A simple stopwatch for measuring code performance. This is a fork from python-stopwatch, which adds static typing and a few other things.

Rafael 2 Feb 18, 2022
Collection of library stubs for Python, with static types

typeshed About Typeshed contains external type annotations for the Python standard library and Python builtins, as well as third party packages as con

Python 3k Jul 9, 2022
Optional static typing for Python 3 and 2 (PEP 484)

Mypy: Optional Static Typing for Python Got a question? Join us on Gitter! We don't have a mailing list; but we are always happy to answer questions o

Python 13.4k Jul 11, 2022
A static analysis tool for Python

pyanalyze Pyanalyze is a tool for programmatically detecting common mistakes in Python code, such as references to undefined variables and some catego

Quora 187 Jun 27, 2022
TidyPy is a tool that encapsulates a number of other static analysis tools and makes it easy to configure, execute, and review their results.

TidyPy Contents Overview Features Usage Docker Configuration Ignoring Issues Included Tools Included Reporters Included Integrations Extending TidyPy

Jason Simeone 32 Apr 24, 2022
Pymwp is a tool for automatically performing static analysis on programs written in C

pymwp: MWP analysis in Python pymwp is a tool for automatically performing static analysis on programs written in C, inspired by "A Flow Calculus of m

Static Analyses of Program Flows: Types and Certificate for Complexity 3 May 15, 2022
Inspects Python source files and provides information about type and location of classes, methods etc

prospector About Prospector is a tool to analyse Python code and output information about errors, potential problems, convention violations and comple

Python Code Quality Authority 1.7k Jul 10, 2022
Performant type-checking for python.

Pyre is a performant type checker for Python compliant with PEP 484. Pyre can analyze codebases with millions of lines of code incrementally – providi

Facebook 6k Jul 14, 2022
Unbearably fast O(1) runtime type-checking in pure Python.

Look for the bare necessities, the simple bare necessities. Forget about your worries and your strife. — The Jungle Book.

null 1.2k Jul 15, 2022
Data parsing and validation using Python type hints

pydantic Data validation and settings management using Python type hinting. Fast and extensible, pydantic plays nicely with your linters/IDE/brain. De

Samuel Colvin 10.4k Jul 12, 2022
Run-time type checker for Python

This library provides run-time type checking for functions defined with PEP 484 argument (and return) type annotations. Four principal ways to do type

Alex Grönholm 937 Jul 11, 2022
Turn your Python and Javascript code into DOT flowcharts

Notes from 2017 This is an older project which I am no longer working on. It was built before ES6 existed and before Python 3 had much usage. While it

Scott Rogowski 2.6k Jul 9, 2022
Find dead Python code

Vulture - Find dead code Vulture finds unused code in Python programs. This is useful for cleaning up and finding errors in large code bases. If you r

Jendrik Seipp 2.2k Jul 10, 2022
Code audit tool for python.

Pylama Code audit tool for Python and JavaScript. Pylama wraps these tools: pycodestyle (formerly pep8) © 2012-2013, Florent Xicluna; pydocstyle (form

Kirill Klenov 900 Jun 30, 2022
The uncompromising Python code formatter

The Uncompromising Code Formatter “Any color you like.” Black is the uncompromising Python code formatter. By using it, you agree to cede control over

Python Software Foundation 28.4k Jul 5, 2022
Print a directory tree structure in your Python code.

directory-structure Print a directory tree structure in your Python code. Download You can simply: pip install directory-structure Or you can also: Cl

Gabriel Stork 41 Jun 13, 2022