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
Enforce the same configuration across multiple projects

Nitpick Flake8 plugin to enforce the same tool configuration (flake8, isort, mypy, Pylint...) across multiple Python projects. Useful if you maintain

Augusto W. Andreoli 315 Dec 25, 2022
Convert relative imports to absolute

absolufy-imports A tool and pre-commit hook to automatically convert relative imports to absolute. Installation $ pip install absolufy-imports Usage a

Marco Gorelli 130 Dec 30, 2022
PEP-484 typing stubs for SQLAlchemy 1.4 and SQLAlchemy 2.0

SQLAlchemy 2 Stubs These are PEP-484 typing stubs for SQLAlchemy 1.4 and 2.0. They are released concurrently along with a Mypy extension which is desi

SQLAlchemy 139 Dec 30, 2022
A python documentation linter which checks that the docstring description matches the definition.

Darglint A functional docstring linter which checks whether a docstring's description matches the actual function/method implementation. Darglint expe

Terrence Reilly 463 Dec 31, 2022
Reference implementation of sentinels for the Python stdlib

Sentinels This is a reference implementation of a utility for the definition of sentinel values in Python. This also includes a draft PEP for the incl

Tal Einat 22 Aug 27, 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 967 Jan 07, 2023
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
Easy saving and switching between multiple KDE configurations.

Konfsave Konfsave is a config manager. That is, it allows you to save, back up, and easily switch between different (per-user) system configurations.

42 Sep 25, 2022
Tool to check the completeness of MANIFEST.in for Python packages

check-manifest Are you a Python developer? Have you uploaded packages to the Python Package Index? Have you accidentally uploaded broken packages with

Marius Gedminas 270 Dec 26, 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
MyPy types for WSGI applications

WSGI Types for Python This is an attempt to bring some type safety to WSGI applications using Python's new typing features (TypedDicts, Protocols). It

Blake Williams 2 Aug 18, 2021
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
A simple plugin that allows running mypy from PyCharm and navigate between errors

mypy-PyCharm-plugin The plugin provides a simple terminal to run fast mypy daemon from PyCharm with a single click or hotkey and easily navigate throu

Dropbox 301 Dec 09, 2022
Mylint - My really simple rendition of how a linter works.

mylint My really simple rendition of how a linter works. This original version was written for my AST article. Since then I've added tests and turned

Tushar Sadhwani 2 Dec 29, 2021
Pymxs, the 3DsMax bindings of Maxscript to Python doesn't come with any stubs

PyMXS Stubs generator What Pymxs, the 3DsMax bindings of Maxscript to Python doe

Frieder Erdmann 19 Dec 27, 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 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 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
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
Pylint plugin to enforce some secure coding standards for Python.

Pylint Secure Coding Standard Plugin pylint plugin that enforces some secure coding standards. Installation pip install pylint-secure-coding-standard

Nguyen Damien 2 Jan 04, 2022