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
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
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 08, 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 04, 2023
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
Pyright extension for coc.nvim

coc-pyright Pyright extension for coc.nvim Install :CocInstall coc-pyright Note: Pyright may not work as expected if can't detect project root correct

Heyward Fann 1.1k Jan 02, 2023
Utilities for refactoring imports in python-like syntax.

aspy.refactor_imports Utilities for refactoring imports in python-like syntax. Installation pip install aspy.refactor_imports Examples aspy.refactor_i

Anthony Sottile 20 Nov 01, 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

1 Feb 12, 2022
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
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 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
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
Flake8 wrapper to make it nice, legacy-friendly, configurable.

THE PROJECT IS ARCHIVED Forks: https://github.com/orsinium/forks It's a Flake8 wrapper to make it cool. Lint md, rst, ipynb, and more. Shareable and r

Life4 232 Dec 16, 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
A simple program which checks Python source files for errors

Pyflakes A simple program which checks Python source files for errors. Pyflakes analyzes programs and detects various errors. It works by parsing the

Python Code Quality Authority 1.2k Dec 30, 2022
Type stubs for the lxml package

lxml-stubs About This repository contains external type annotations (see PEP 484) for the lxml package. Installation To use these stubs with mypy, you

25 Dec 26, 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
Simple Python style checker in one Python file

pycodestyle (formerly called pep8) - Python style guide checker pycodestyle is a tool to check your Python code against some of the style conventions

Python Code Quality Authority 4.7k Jan 01, 2023
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 checking quotes in python

Flake8 Extension to lint for quotes. Major update in 2.0.0 We automatically encourage avoiding escaping quotes as per PEP 8. To disable this, use --no

Zachary Heller 157 Dec 13, 2022