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
❄️ 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
Flake8 plugin that checks import order against various Python Style Guides

flake8-import-order A flake8 and Pylama plugin that checks the ordering of your imports. It does not check anything else about the imports. Merely tha

Python Code Quality Authority 270 Nov 24, 2022
flake8 plugin that integrates isort

Flake8 meet isort Use isort to check if the imports on your python files are sorted the way you expect. Add an .isort.cfg to define how you want your

Gil Forcada Codinachs 139 Nov 8, 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 Pylint plugin to analyze Flask applications.

pylint-flask About pylint-flask is Pylint plugin for improving code analysis when editing code using Flask. Inspired by pylint-django. Problems pylint

Joe Schafer 62 Sep 18, 2022
flake8 plugin to run black for checking Python coding style

flake8-black Introduction This is an MIT licensed flake8 plugin for validating Python code style with the command line code formatting tool black. It

Peter Cock 146 Dec 15, 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
A plugin for Flake8 that checks pandas code

pandas-vet pandas-vet is a plugin for flake8 that provides opinionated linting for pandas code. It began as a project during the PyCascades 2019 sprin

Jacob Deppen 146 Dec 28, 2022
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

null 1 Feb 12, 2022
Pytest-typechecker - Pytest plugin to test how type checkers respond to code

pytest-typechecker this is a plugin for pytest that allows you to create tests t

vivax 2 Aug 20, 2022
A pytest plugin to run an ansible collection's unit tests with pytest.

pytest-ansible-units An experimental pytest plugin to run an ansible collection's unit tests with pytest. Description pytest-ansible-units is a pytest

Community managed Ansible repositories 9 Dec 9, 2022
pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-dev 1.1k Dec 14, 2022
ApiPy was created for api testing with Python pytest framework which has also requests, assertpy and pytest-html-reporter libraries.

ApiPy was created for api testing with Python pytest framework which has also requests, assertpy and pytest-html-reporter libraries. With this f

Mustafa 1 Jul 11, 2022
Playwright Python tool practice pytest pytest-bdd screen-play page-object allure cucumber-report

pytest-ui-automatic Playwright Python tool practice pytest pytest-bdd screen-play page-object allure cucumber-report How to run Run tests execute_test

moyu6027 11 Nov 8, 2022
Pytest-rich - Pytest + rich integration (proof of concept)

pytest-rich Leverage rich for richer test session output. This plugin is not pub

Bruno Oliveira 170 Dec 2, 2022
A Django plugin for pytest.

Welcome to pytest-django! pytest-django allows you to test your Django project/applications with the pytest testing tool. Quick start / tutorial Chang

pytest-dev 1.1k Dec 31, 2022
A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax

1.0 Release See here for details about breaking changes with the upcoming 1.0 release: https://github.com/taverntesting/tavern/issues/495 Easier API t

null 909 Dec 15, 2022
Coverage plugin for pytest.

Overview docs tests package This plugin produces coverage reports. Compared to just using coverage run this plugin does some extras: Subprocess suppor

pytest-dev 1.4k Dec 29, 2022
pytest plugin for distributed testing and loop-on-failures testing modes.

xdist: pytest distributed testing plugin The pytest-xdist plugin extends pytest with some unique test execution modes: test run parallelization: if yo

pytest-dev 1.1k Dec 30, 2022
Plugin for generating HTML reports for pytest results

pytest-html pytest-html is a plugin for pytest that generates a HTML report for test results. Resources Documentation Release Notes Issue Tracker Code

pytest-dev 548 Dec 28, 2022