Stubs with type annotations for ordered-set Python library

Overview

ordered-set-stubs - stubs with type annotations for ordered-set Python library

Archived - now type annotations are the part of the ordered-set library itself.

Usage

For example, you have the following code in ordered_set_stubs_test.py file:

from ordered_set import OrderedSet


# noinspection PyPep8Naming
def receives_OrderedSet_int(ordered_set: 'OrderedSet[int]') -> 'OrderedSet[int]':
    return ordered_set


receives_OrderedSet_int(OrderedSet(['ololo']))

Run mypy to check the code and check that it returns an error:

$ mypy ordered_set_stubs_test.py
ordered_set_stubs_test.py:10: error: List item 0 has incompatible type "str"; expected "int"

In Python 3.7 you can even drop quotes:

from __future__ import annotations
from ordered_set import OrderedSet


# noinspection PyPep8Naming
def receives_OrderedSet_int(ordered_set: OrderedSet[int]) -> OrderedSet[int]:
    return ordered_set


receives_OrderedSet_int(OrderedSet(['ololo']))
You might also like...
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

The strictest and most opinionated python linter ever!
The strictest and most opinionated python linter ever!

wemake-python-styleguide Welcome to the strictest and most opinionated python linter ever. wemake-python-styleguide is actually a flake8 plugin with s

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

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

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

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

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):

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

Custom Python linting through AST expressions
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

Comments
  • Cannot determine consistent method resolution order (MRO) for

    Cannot determine consistent method resolution order (MRO) for "OrderedSet" when used with Python 2.7

    I have installed those stubs for Python 2.7 and am manipulating mypy to find them, by running mypy as follows (~/v27 is a virtualenv):

    mypy test.py --python-version 2.7 --python-executable~/v27/bin/python
    

    This give me the error

    /Users/guido/v27/lib/python2.7/site-packages/ordered_set-stubs/__init__.pyi:10: error: Cannot determine consistent method resolution order (MRO) for "OrderedSet"
    

    When used with Python 3 all is well.

    opened by gvanrossum 2
  • Consider using pytest-mypy-plugins

    Consider using pytest-mypy-plugins

    Hi! Thanks for this awesome project!

    I am TypedDjango team member, we maintain types for, well, django. And we do pretty much the same job.

    For example, we also test our types the similar way as you do in tests/. We even created a tool called pytest-mypy-plugins (announcing post) to help us with this task. Maybe it will be also helpful to you as well.

    That's how the simplest test looks like:

    - case: compose_two_wrong_functions
      main: |
        from returns.functions import compose
    
        def first(num: int) -> float:
            return float(num)
    
        def second(num: float) -> str:
            return str(num)
    
        reveal_type(compose(first, second)(1))  # N: builtins.str*
    

    Ask any questions you have!

    opened by sobolevn 0
Owner
Roman Inflianskas
Roman Inflianskas
open source tools to generate mypy stubs from protobufs

mypy-protobuf: Generate mypy stub files from protobuf specs We just released a new major release mypy-protobuf 2. on 02/02/2021! It includes some back

Dropbox 527 Jan 3, 2023
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
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 4, 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.2k Jan 3, 2023
Unbearably fast O(1) runtime type-checking in pure Python.

Look for the bare necessities, the simple bare necessities. Forget about your worries and your strife. — The Jungle Book.

beartype 1.4k Jan 1, 2023
❄️ 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
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 1, 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 8, 2023
A Python Parser

parso - A Python Parser Parso is a Python parser that supports error recovery and round-trip parsing for different Python versions (in multiple Python

Dave Halter 520 Dec 26, 2022