yetone / olo-stubs

Mypy plugin and stubs for OLO ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mypy logo

Mypy plugin and stubs for OLO inspired by sqlalchemy-stubs

Build Status Checked with mypy

This package contains type stubs and a mypy plugin to provide more precise static types and type inference for OLO framework. A simple example:

from olo import Model, Field

class BaseModel(Model):
    pass

class User(BaseModel):
    __table_name__ = 'users'
    id = Field(int, primary_key=True)
    name = Field(str)

user: User
reveal_type(user.id)  # N: Revealed type is 'builtins.int*'
reveal_type(User.name)  # N: Revealed type is 'olo.field.Field[builtins.str]'

Installation

Install latest published version as:

pip install -U olo-stubs

Important: you need to enable the plugin in your mypy config file:

[mypy]
plugins = olomypy

To install the development version of the package:

git clone https://github.com/yetone/olo-stubs
cd olo-stubs
pip install -U .

Development Setup

First, clone the repo and cd into it, like in Installation, then:

git submodule update --init --recursive
pip install -r dev-requirements.txt

Then, to run the tests, simply:

pytest

About

Mypy plugin and stubs for OLO ORM


Languages

Language:Python 100.0%