A system for Python that generates static type annotations by collecting runtime types

Overview

MonkeyType

MonkeyType collects runtime types of function arguments and return values, and can automatically generate stub files or even add draft type annotations directly to your Python code based on the types collected at runtime.

Example

Say some/module.py originally contains:

def add(a, b):
    return a + b

And myscript.py contains:

from some.module import add

add(1, 2)

Now we want to infer the type annotation of add in some/module.py by running myscript.py with MonkeyType. One way is to run:

$ monkeytype run myscript.py

By default, this will dump call traces into a SQLite database in the file monkeytype.sqlite3 in the current working directory. You can then use the monkeytype command to generate a stub file for a module, or apply the type annotations directly to your code.

Running monkeytype stub some.module will output a stub:

def add(a: int, b: int) -> int: ...

Running monkeytype apply some.module will modify some/module.py to:

def add(a: int, b: int) -> int:
    return a + b

This example demonstrates both the value and the limitations of MonkeyType. With MonkeyType, it's very easy to add annotations that reflect the concrete types you use at runtime, but those annotations may not always match the full intended capability of the functions. For instance, add is capable of handling many more types than just integers. Similarly, MonkeyType may generate a concrete List annotation where an abstract Sequence or Iterable would be more appropriate. MonkeyType's annotations are an informative first draft, to be checked and corrected by a developer.

Motivation

Readability and static analysis are the primary motivations for adding type annotations to code. It's already common in many Python style guides to document the argument and return types for a function in its docstring; annotations are a standardized way to provide this documentation, which also permits static analysis by a typechecker such as mypy.

For more on the motivation and design of Python type annotations, see PEP 483 and PEP 484.

Requirements

MonkeyType requires Python 3.6+ and the libcst library (for applying type stubs to code files). It generates only Python 3 type annotations (no type comments).

Installing

Install MonkeyType with pip:

pip install MonkeyType

How MonkeyType works

MonkeyType uses the sys.setprofile hook provided by Python to interpose on function calls, function returns, and generator yields, and record the types of arguments / return values / yield values.

It generates stub files based on that data, and can use libcst to apply those stub files directly to your code.

See the full documentation for details.

Troubleshooting

Check if your issue is mentioned in the frequently asked questions list.

Development

See CONTRIBUTING.rst for information on developing and contributing to MonkeyType.

LICENSE

MonkeyType is BSD licensed.

Comments
  • Python 3.9 AttributeError: __args__

    Python 3.9 AttributeError: __args__

    I honestly cannot parse this error message.

    I'm trying to run monkeytype on manim's mobject.py

    monkeytype stub manim.mobject.mobject
    
    Traceback (most recent call last):
      File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "C:\Python39\lib\runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "C:\Users\ethan\AppData\Local\pypoetry\Cache\virtualenvs\manim-ob3XvX2_-py3.9\Scripts\monkeytype.exe\__main__.py", line 7, in <module>
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\cli.py", line 396, in entry_point_main
        sys.exit(main(sys.argv[1:], sys.stdout, sys.stderr))
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\cli.py", line 381, in main
        handler(args, stdout, stderr)
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\cli.py", line 199, in print_stub_handler
        stub = get_stub(args, stdout, stderr)
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\cli.py", line 126, in get_stub
        stubs = build_module_stubs_from_traces(
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\stubs.py", line 819, in build_module_stubs_from_traces
        return build_module_stubs(defns)
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\stubs.py", line 784, in build_module_stubs
        imports = get_imports_for_signature(entry.signature)
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\stubs.py", line 157, in get_imports_for_signature
        param_imports = get_imports_for_annotation(param.annotation)
      File "c:\users\ethan\appdata\local\pypoetry\cache\virtualenvs\manim-ob3xvx2_-py3.9\lib\site-packages\monkeytype\stubs.py", line 143, in get_imports_for_annotation
        elem_types = anno.__args__ or []
      File "C:\Python39\lib\typing.py", line 694, in __getattr__
        raise AttributeError(attr)
    AttributeError: __args__
    
    opened by GameDungeon 28
  • TypeVar instances also lack `__qualname__`

    TypeVar instances also lack `__qualname__`

    Sharing a quick fix I needed to get to work on some of the projects I quickly gave this a shot on. It choked on trying to serialize TypeVar instances as it seems like it also lacks __qualname__.

    CLA Signed 
    opened by vodik 18
  • Getting '_SpecialForm' object has no attribute '__name__'

    Getting '_SpecialForm' object has no attribute '__name__'

    I'm getting this error running monkeytype 21.5 on python 3.8:

    monkeytype run -m pytest tests
    Failed collecting trace
    Traceback (most recent call last):
      File "path\to\env\lib\site-packages\monkeytype\tracing.py", line 259, in __call__
        self.handle_call(frame)
      File "path\to\env\lib\site-packages\monkeytype\tracing.py", line 225, in handle_call
        arg_types[name] = get_type(frame.f_locals[name],
      File "path\to\env\lib\site-packages\monkeytype\typing.py", line 190, in get_type
        return get_dict_type(obj, max_typed_dict_size)
      File "path\to\env\lib\site-packages\monkeytype\typing.py", line 170, in get_dict_type
        val_type = shrink_types((get_type(v, max_typed_dict_size) for v in dct.values()), max_typed_dict_size)
      File "path\to\env\lib\site-packages\monkeytype\typing.py", line 133, in shrink_types
        annotation = shrink_types((getattr(typ, '__args__')[0] for typ in types), max_typed_dict_size)
      File "path\to\env\lib\site-packages\monkeytype\typing.py", line 132, in shrink_types
        if all(is_list(typ) for typ in types):
      File "path\to\env\lib\site-packages\monkeytype\typing.py", line 132, in <genexpr>
        if all(is_list(typ) for typ in types):
      File "path\to\env\lib\site-packages\monkeytype\typing.py", line 54, in is_list
        return is_generic(typ) and name_of_generic(typ) == 'List'
      File "path\to\env\lib\site-packages\monkeytype\compat.py", line 43, in name_of_generic
        return typ._name or typ.__origin__.__name__
    AttributeError: '_SpecialForm' object has no attribute '__name__'
    

    Using 20.5 works correctly instead. This happens while running monkeytype on alembic.

    To reproduce (commit e31971cfb46efd0ef41525473a1d9bcb81e90f43 is the current head of alembic):

    git clone https://github.com/sqlalchemy/alembic.git
    cd alembic
    git checkout e31971cfb46efd0ef41525473a1d9bcb81e90f43
    pip install -e .
    pip install python-dateutil
    monkeytype run -m pytest tests
    
    need-info 
    opened by CaselIT 12
  • Allow typing specified modules in site-packages

    Allow typing specified modules in site-packages

    #82

    This PR allows users to define an environment variable MONKEYTYPE_MODULE with name of a module, which would be typed by MonkeyType even if it is under Python site-packages.

    CLA Signed 
    opened by BoPeng 12
  • `monkeytype run manage.py test` doesn't produce sqllite file

    `monkeytype run manage.py test` doesn't produce sqllite file

    I've run monkeytype run manage.py test in my django project after pip install monkeytype (inside of a virtual env) and I'm not seeing any output of the sqllite file described in the README.

    Running monkeytype stub for any of my modules doesn't work either. If there's something different that I have to do for django tests, let's add that to the README. Otherwise, am I missing something?

    opened by nsillik 10
  • record per-key types for heterogenous dicts and suggest TypedDict annotation

    record per-key types for heterogenous dicts and suggest TypedDict annotation

    Currently MonkeyType assumes dicts are homogenous. When heterogenous dicts are seen, we just combine all the value types into a Union (and then if that Union gets too big, by default we rewrite it to Any). It'd be more useful in such cases to suggest a TypedDict annotation with per-key value types.

    The trick here is that we don't really know the intention, so there'd be some level of heuristic involved. Like, if there's multiple non-None value types (and probably if the number of keys is less than some threshold), rather than recording just a single value type, we record per-key value types. Then we'd also need some smarts when combining traces into an annotation: if we have any traces with per-key value types, try to construct a consistent TypedDict, but if we find that key names and value types aren't matching up consistently, fallback to normal Dict.

    There's enough fuzziness in the heuristics here and this'd be enough work that it might not be worth it, but for codebases that use lots of heterogenous dicts, it'd make the generated annotations a lot more useful.

    enhancement 
    opened by carljm 9
  • demo example tests are not passing at 100% on Windows

    demo example tests are not passing at 100% on Windows

    I tried to run the demo but I got:

    monkeytype\demo>pytest
    ============================= test session starts =============================
    platform win32 -- Python 3.6.1, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
    rootdir: monkeytype\demo, inifile: pytest.ini
    plugins: cov-2.5.1
    collected 8 items
    
    test_inbox.py ......F.                                                   [100%]
    
    ================================== FAILURES ===================================
    _______________________________ test_everything _______________________________
    
        def test_everything():
            u = make_user()
            other = make_user(name="Other", following=[u.id])
            first_entry = make_feedentry(user_id=u.id, caption="My First Post")
            follow = make_followed(user_id=u.id, follower_id=other.id)
            second_entry = make_feedentry(user_id=u.id, caption="Second Post")
            like1 = make_liked(user_id=u.id, liker_id=other.id, feedentry_id=first_entry.id)
            comment = make_commented(
                user_id=u.id, commenter_id=other.id, feedentry_id=first_entry.id
            )
            like2 = make_liked(user_id=u.id, liker_id=other.id, feedentry_id=second_entry.id)
            repo = FakeRepo(u, other, first_entry, second_entry, like1, like2, comment, follow)
            box = inbox.Inbox(u, repo)
    
    >       assert (
                box.aggregate()
                == [
                    models.AggregatedItem(
                        type=models.EventType.LIKED,
                        text='Other liked your post "Second Post".',
                        published=like2.published,
                    ),
                    models.AggregatedItem(
                        type=models.EventType.COMMENTED,
                        text="Other commented on your post.",
                        published=comment.published,
                    ),
                    models.AggregatedItem(
                        type=models.EventType.LIKED,
                        text='Other liked your post "My First Post".',
                        published=like1.published,
                    ),
                    models.AggregatedItem(
                        type=models.EventType.FOLLOWED,
                        text="Other started following you.",
                        published=follow.published,
                    ),
                ]
            )
    E       assert [AggregatedIt... 26, 231564))] == [AggregatedIte... 26, 231564))]
    E         At index 0 diff: AggregatedItem(type=<EventType.COMMENTED: 'commented'>, text='Other commented on your post.', published=datetime.datetime(2018, 7, 25, 6, 38, 26, 231564)) != AggregatedItem(type=<EventType.LIKED: 'liked'>, text='Other liked your post "Second Post".', published=datetime.datetime(2018, 7, 25, 6, 38, 26, 231564))
    E         Use -v to get the full diff
    
    test_inbox.py:242: AssertionError
    
    ----------- coverage: platform win32, python 3.6.1-final-0 -----------
    Name       Stmts   Miss Branch BrPart  Cover   Missing
    ------------------------------------------------------
    inbox.py      87      2     33      1    98%   163-164, 160->163
    Coverage HTML written to dir htmlcov
    
    ===================== 1 failed, 7 passed in 0.38 seconds ======================
    
    monkeytype\demo>
    
    opened by bluebird75 9
  • MonkeyType is not working in IPython

    MonkeyType is not working in IPython

    The newer version of MonkeyType does not work in IPython. I think https://github.com/Instagram/MonkeyType/commit/e8bb8a687e18dbb3c734ef33501a573265465c9d could be the reason.

    An interactive session in IPython will assert __name__ == '__main__' it would still be meaningful to capture the CallTrace so folks could interactively type their notebook/python source.

    I can totally understand if this falls outside the scope of the project.

    bug 
    opened by tonyfast 9
  • cannot use MonkeyType on Azure App Services filesystem: `sqlite3.OperationalError: database is locked`

    cannot use MonkeyType on Azure App Services filesystem: `sqlite3.OperationalError: database is locked`

    I've been attempting to get MonkeyType 21.5.0 to work in AzureML, which uses Ubuntu VMs for compute instances. However, after multiple attempts in both Python 3.6.9 and 3.8.1, every command, version, and file I've tried returns the same error trace:

    Traceback (most recent call last):
      File "/anaconda/envs/azureml_py38/bin/monkeytype", line 8, in <module>
        sys.exit(entry_point_main())
      File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/monkeytype/cli.py", line 396, in entry_point_main
        sys.exit(main(sys.argv[1:], sys.stdout, sys.stderr))
      File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/monkeytype/cli.py", line 381, in main
        handler(args, stdout, stderr)
      File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/monkeytype/cli.py", line 210, in list_modules_handler
        modules = args.config.trace_store().list_modules()
      File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/monkeytype/config.py", line 147, in trace_store
        return SQLiteStore.make_store(db_path)
      File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/monkeytype/db/sqlite.py", line 82, in make_store
        create_call_trace_table(conn)
      File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/monkeytype/db/sqlite.py", line 45, in create_call_trace_table
        conn.execute(query)
    sqlite3.OperationalError: database is locked
    

    The sqlite3 DB is being created, but the connection isn't being closed correctly despite the with statement in line 44 of ./monkeytype/db/sqlite.py. Is there any way to config the context manager for the sqlite DB?

    opened by ColtAllen 8
  • monkeytype/typing.py import error in PyCharm

    monkeytype/typing.py import error in PyCharm

    Trying to set up dev environment per instructions in CONTRIBUTING.rst

    Getting an import error: Traceback (most recent call last): File "/home/johnar/github/MonkeyType/monkeytype/cli.py", line 17, in from typing import ( File "/home/johnar/github/MonkeyType/monkeytype/typing.py", line 10, in from typing import ( ImportError: cannot import name 'Any'

    In pycharm it actually shows that import _Any and _Union result in unresolved reference, as they're not defined in the typing module.

    This is with stdlib typing 3.6.4: typing 3.6.4

    opened by johnarnold 8
  • monkeytype / retype doesn't apply stubs in __init__.py

    monkeytype / retype doesn't apply stubs in __init__.py

    For one of my modules, I ran test cases via monketype run, I can see the traces in the sqlite3 database, and I can run 'monketype stub modulename' and see what looks like valid stub output.

    However, when I run 'monkeytype apply modulename', it returns no errors but the module is not modified.

    I've been able to successfully update other modules. This module is my only good repro so far. There are no errors anywhere. I'm open to ideas on how to proceed. I guess i can start with debugging monkeytype?

    bug 
    opened by johnarnold 8
  • Support PEP 604 Union syntax  (Union[a, b] → a | b)

    Support PEP 604 Union syntax (Union[a, b] → a | b)

    PEP 604 introduces a new Union syntax in Python 3.10+. It would be nice if Monkeytype could leverage that, and perhaps have a flag to use a union with None rather than the Optional type.

    # Old syntax
    def foo(a: Optional[Union[float, int]]) -> Optional[float]:
        ...
    
    # New syntax
    def foo(a: float | int | None) -> float | None:
        ...
    
    enhancement 
    opened by AllanLeanderRostockHansen 0
  • Traces with builtins.coroutine, builtins.async_generator fail to decode

    Traces with builtins.coroutine, builtins.async_generator fail to decode

    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'async_generator'
    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'async_generator'
    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'async_generator'
    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'coroutine'
    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'coroutine'
    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'coroutine'
    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'coroutine'
    WARNING: Failed decoding trace: Module 'builtins' has no attribute 'coroutine'
    

    Got the above in verbose mode when running Python 3.6.15 and MonkeyType 21.5.0 .

    Should these be in the following? https://github.com/Instagram/MonkeyType/blob/cef09c6702fbab58e66582f76f2559d6a21e448c/monkeytype/encoding.py#L97-L102

    And are there any other async or builtin types that need this special handling?

    Even though traces that don't decode usually get ignored, async types are probably very meaningful for the codebase.

    bug 
    opened by slix 1
  • "Failed collecting trace" and then lots of exceptions

    Should be a pretty easy repro.

    Create a Dockerfile with the following contents:

    FROM ubuntu:20.04
    RUN apt-get update
    RUN apt-get install -y python3 python3-pip
    RUN pip3 install monkeytype
    RUN echo "from pkg_resources.extern import six" > repro.py
    

    Then build it with docker build --network=host -t repro . and start with docker run --rm -it repro bash (or whatever).

    Can verify that the import works correctly:

    root@2ed6e4080312:/# python3 repro.py
    root@2ed6e4080312:/#
    

    (python3 here is 3.8)

    But this doesn't work through MonkeyType:

    root@2ed6e4080312:/# monkeytype run repro.py
    Failed collecting trace
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/monkeytype/tracing.py", line 259, in __call__
        self.handle_call(frame)
      File "/usr/local/lib/python3.8/dist-packages/monkeytype/tracing.py", line 213, in handle_call
        func = self._get_func(frame)
      File "/usr/local/lib/python3.8/dist-packages/monkeytype/tracing.py", line 207, in _get_func
        self.cache[code] = get_func(frame)
      File "/usr/local/lib/python3.8/dist-packages/monkeytype/tracing.py", line 151, in get_func
        func = get_func_in_mro(first_arg, code)
      File "/usr/local/lib/python3.8/dist-packages/monkeytype/tracing.py", line 113, in get_func_in_mro
        val = inspect.getattr_static(obj, code.co_name, None)
      File "/usr/lib/python3.8/inspect.py", line 1596, in getattr_static
        instance_result = _check_instance(obj, attr)
      File "/usr/lib/python3.8/inspect.py", line 1546, in _check_instance
        return dict.get(instance_dict, attr, _sentinel)
    TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object
    ...
    ...
    
    bug 
    opened by EvanED 1
  • Less scary output on failed collecting trace warnings

    Less scary output on failed collecting trace warnings

    We don't need to print the full traceback, and we could probably hint people that even if a few traces failed to collect that doesn't mean useful type traces weren't still collected.

    See e.g. #244

    enhancement 
    opened by carljm 0
  • failed collecting trace: TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object

    failed collecting trace: TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object

    First time using this tool, after watching the utoob discussion. No type info whatsoever in my code, but I was prepared to be converted, and was interested to get a leg up with this tool.

    monkeytype run zwi/zwi.py Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Failed collecting trace Traceback (most recent call last): File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 259, in __call__ self.handle_call(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 213, in handle_call func = self._get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 207, in _get_func self.cache[code] = get_func(frame) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 151, in get_func func = get_func_in_mro(first_arg, code) File "/Users/dap/Library/Python/3.9/lib/python/site-packages/monkeytype/tracing.py", line 113, in get_func_in_mro val = inspect.getattr_static(obj, code.co_name, None) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1622, in getattr_static instance_result = _check_instance(obj, attr) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/inspect.py", line 1572, in _check_instance return dict.get(instance_dict, attr, _sentinel) TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'NoneType' object Usage: python -m zwi [OPTIONS] COMMAND [ARGS]...

    need-info 
    opened by permezel 5
Owner
Instagram
Instagram
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 3.3k Jan 2, 2023
A static type analyzer for Python code

pytype - ? ✔ Pytype checks and infers types for your Python code - without requiring type annotations. Pytype can: Lint plain Python code, flagging c

Google 4k Dec 31, 2022
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 9.4k Jan 7, 2023
Auto-generate PEP-484 annotations

PyAnnotate: Auto-generate PEP-484 annotations Insert annotations into your source code based on call arguments and return types observed at runtime. F

Dropbox 1.4k Dec 26, 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 14.4k Jan 5, 2023
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 212 Jan 7, 2023
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 33 Nov 27, 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 132 Dec 29, 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 2 Dec 2, 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.3k Jan 7, 2023
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
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 Dec 31, 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 6.2k Jan 7, 2023
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 12.1k Jan 5, 2023
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 1.1k Dec 19, 2022
pycallgraph is a Python module that creates call graphs for Python programs.

Project Abandoned Many apologies. I've stopped maintaining this project due to personal time constraints. Blog post with more information. I'm happy t

gak 1.7k Jan 1, 2023
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 3k Jan 9, 2023
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.4k Jan 3, 2023
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 966 Dec 29, 2022