MonkeyType as a pytest plugin.

Overview

pytest-monkeytype

Build Status License PyPI Python PyPI Version PyPI Status PyPI Wheel

MonkeyType as a pytest plugin.

pip install pytest-monkeytype

# Generate annotations by running your pytest tests as usual:
py.test --monkeytype-output=./monkeytype.sqlite3

# Get a listing of modules annotated by monkeytype
monkeytype list-modules

# Generate a stub file for those annotations using monkeytype:
monkeytype stub some.module

# Apply these annotations directly
monkeytype apply some.module

This project is inspired by pytest-annotate

Comments
  • Fix CallTracer constructor call: #2

    Fix CallTracer constructor call: #2

    This PR aims to fix #2. I also encountered the same error as #2. CallTracer constructor added max_typed_dict_size as a positional argument since MonkeyType 20.4.1 or later.

    opened by thombashi 3
  • Trying to run pytest-monkeytype

    Trying to run pytest-monkeytype

    I have tried to use this plugin, it didn't work 🙂

    Here's the error message I got:

    » py.test --monkeytype-output=./monkeytype.sqlite3
    /Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pytest_benchmark/logger.py:44: PytestBenchmarkWarning: Can't compare. No benchmark files in '/Users/sobolev/Desktop/dramatiq/.benchmarks'. Can't load the previous benchmark.
      warner(PytestBenchmarkWarning(text))
    ================================ test session starts =================================
    platform darwin -- Python 3.7.7, pytest-3.10.1, py-1.8.1, pluggy-0.13.1
    benchmark: 3.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
    rootdir: /Users/sobolev/Desktop/dramatiq, inifile: setup.cfg
    plugins: benchmark-3.2.3, cov-2.8.1, monkeytype-1.0.5
    collected 242 items                                                                  
    INTERNALERROR> Traceback (most recent call last):
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/_pytest/main.py", line 184, in wrap_session
    INTERNALERROR>     session.exitstatus = doit(config, session) or 0
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/_pytest/main.py", line 223, in _main
    INTERNALERROR>     config.hook.pytest_collection(session=session)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR>     return outcome.get_result()
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR>     raise ex[1].with_traceback(ex[2])
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/_pytest/main.py", line 233, in pytest_collection
    INTERNALERROR>     return session.perform_collect()
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/_pytest/main.py", line 437, in perform_collect
    INTERNALERROR>     hook.pytest_collection_finish(session=self)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR>     return outcome.get_result()
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR>     raise ex[1].with_traceback(ex[2])
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pytest_monkeytype/plugin.py", line 40, in pytest_collection_finish
    INTERNALERROR>     sample_rate=None,
    INTERNALERROR> TypeError: __init__() missing 1 required positional argument: 'max_typed_dict_size'
    /Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pytest_benchmark/logger.py:44: PytestBenchmarkWarning: Not saving anything, no benchmarks have been run!
      warner(PytestBenchmarkWarning(text))
    

    Versions:

    » pytest --version
    This is pytest version 3.10.1, imported from /Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pytest.py
    setuptools registered plugins:
      pytest-benchmark-3.2.3 at /Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pytest_benchmark/plugin.py
      pytest-cov-2.8.1 at /Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pytest_cov/plugin.py
      pytest-monkeytype-1.0.5 at /Users/sobolev/Desktop/dramatiq/.venv/lib/python3.7/site-packages/pytest_monkeytype/plugin.py
    
    opened by sobolevn 1
  • Bugfix/trace logger

    Bugfix/trace logger

    I hit a problem with self.trace.logger being None so when I went to fix it, I noticed several other issues, such as logger not currently being part of the documented CallTracer interface.

    Hope these changes help!

    Also, is it true for MonkeyType that importing CallTracer should wait until after collection? I know that's how pytest-annotate does it but I think that might be due to the way PyAnnotate works which is different for MonkeyType. (I readily admit that I do not know much about gevent.)

    opened by wcooley 0
  • ERROR: Failed building wheel for pytest-monkeytype

    ERROR: Failed building wheel for pytest-monkeytype

    $ python --version
    Python 3.8.10
    

    Trying: pip install pytest-monkeytype

    output

      ERROR: Command errored out with exit status 1:
       command: /home/jonathan/develop/selenium-python-helium/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sfwdi49o/pytest-monkeytype/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sfwdi49o/pytest-monkeytype/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ylsggp4t
           cwd: /tmp/pip-install-sfwdi49o/pytest-monkeytype/
      Complete output (6 lines):
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help
      
      error: invalid command 'bdist_wheel'
      ----------------------------------------
      ERROR: Failed building wheel for pytest-monkeytype
    
    opened by jonathanelscpt 1
  • No hook for custom configuration

    No hook for custom configuration

    I need to configure MonkeyType but this plugin does not allow to provide custom configuration. Usually pytest plugins can be configured using fixtures.

    opened by thedrow 0
Owner
Marius van Niekerk
Full stack data scientist
Marius van Niekerk
Rust like Option and Result types in Python

Option Rust-like Option and Result types in Python, slotted and fully typed. An Option type represents an optional value, every Option is either Some

45 Dec 13, 2022
Flake8 plugin to find commented out or dead code

flake8-eradicate flake8 plugin to find commented out (or so called "dead") code. This is quite important for the project in a long run. Based on eradi

wemake.services 277 Dec 27, 2022
A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.

flake8-bugbear A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycode

Python Code Quality Authority 869 Dec 30, 2022
Check for python builtins being used as variables or parameters

Flake8 Builtins plugin Check for python builtins being used as variables or parameters. Imagine some code like this: def max_values(list, list2):

Gil Forcada Codinachs 98 Jan 08, 2023
Pylint plugin for improving code analysis for when using Django

pylint-django About pylint-django is a Pylint plugin for improving code analysis when analysing code using Django. It is also used by the Prospector t

Python Code Quality Authority 544 Jan 06, 2023
Collection of awesome Python types, stubs, plugins, and tools to work with them.

Awesome Python Typing Collection of awesome Python types, stubs, plugins, and tools to work with them. Contents Static type checkers Dynamic type chec

TypedDjango 1.2k Jan 04, 2023
flake8 plugin to catch useless `assert` statements

flake8-useless-assert flake8 plugin to catch useless assert statements Download or install on the PyPI page Violations Code Description Example ULA001

1 Feb 12, 2022
MonkeyType as a pytest plugin.

MonkeyType as a pytest plugin.

Marius van Niekerk 36 Nov 24, 2022
Utilities for pycharm code formatting (flake8 and black)

Pycharm External Tools Extentions to Pycharm code formatting tools. Currently supported are flake8 and black on a selected code block. Usage Flake8 [P

Haim Daniel 13 Nov 03, 2022
Custom Python linting through AST expressions

bellybutton bellybutton is a customizable, easy-to-configure linting engine for Python. What is this good for? Tools like pylint and flake8 provide, o

H. Chase Stevens 249 Dec 31, 2022
Stubs with type annotations for ordered-set Python library

ordered-set-stubs - stubs with type annotations for ordered-set Python library Archived - now type annotations are the part of the ordered-set library

Roman Inflianskas 2 Feb 06, 2020
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 08, 2023
Flake8 extension for enforcing trailing commas in python

Flake8 Extension to enforce better comma placement. Usage If you are using flake8 it's as easy as: pip install flake8-commas Now you can avoid those a

Python Code Quality Authority 127 Sep 03, 2022
👻 Phantom types for Python

phantom-types Phantom types for Python will help you make illegal states unrepresentable and avoid shotgun parsing by enabling you to practice "Parse,

Anton Agestam 118 Dec 22, 2022
Mypy plugin and stubs for SQLAlchemy

Pythonista Stubs Stubs for the Pythonista iOS API. This allows for better error detection and IDE / editor autocomplete. Installation and Usage pip in

Dropbox 521 Dec 29, 2022
Mypy stubs for the PyQt5 framework

Mypy stubs for the PyQt5 framework This repository holds the stubs of the PyQt5 framework. It uses the stub files that are produced during compilation

62 Nov 22, 2022
A plugin for flake8 integrating Mypy.

flake8-mypy NOTE: THIS PROJECT IS DEAD It was created in early 2017 when Mypy performance was often insufficient for in-editor linting. The Flake8 plu

Łukasz Langa 103 Jun 23, 2022
Tool for pinpointing circular imports in Python. Find cyclic imports in any project

Pycycle: Find and fix circular imports in python projects Pycycle is an experimental project that aims to help python developers fix their circular de

Vadim Kravcenko 311 Dec 15, 2022
❄️ A flake8 plugin to help you write better list/set/dict comprehensions.

flake8-comprehensions A flake8 plugin that helps you write better list/set/dict comprehensions. Requirements Python 3.6 to 3.9 supported. Installation

Adam Johnson 398 Dec 23, 2022
A static-analysis bot for Github

Imhotep, the peaceful builder. What is it? Imhotep is a tool which will comment on commits coming into your repository and check for syntactic errors

Justin Abrahms 221 Nov 10, 2022