https://github.com/yetone/olo-stubs
Mypy plugin and stubs for OLO ORM
https://github.com/yetone/olo-stubs
Last synced: over 1 year ago
JSON representation
Mypy plugin and stubs for OLO ORM
- Host: GitHub
- URL: https://github.com/yetone/olo-stubs
- Owner: yetone
- Created: 2020-01-17T11:40:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-15T06:42:35.000Z (over 5 years ago)
- Last Synced: 2025-02-17T07:50:03.049Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 69.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

Mypy plugin and stubs for [OLO](https://github.com/yetone/olo) inspired by [sqlalchemy-stubs](https://github.com/dropbox/sqlalchemy-stubs)
====================================
[](https://travis-ci.org/yetone/olo-stubs)
[](http://mypy-lang.org/)
This package contains [type stubs](https://www.python.org/dev/peps/pep-0561/) and a
[mypy plugin](https://mypy.readthedocs.io/en/latest/extending_mypy.html#extending-mypy-using-plugins)
to provide more precise static types and type inference for
[OLO framework](https://github.com/yetone/olo). A simple example:
```python
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
```