Skip to content

Commit fa4eeda

Browse files
authored
Merge pull request #193 from graphql-python/statictypes
Added Static typing using type annotations and mypy
2 parents 042acf9 + e6d11f6 commit fa4eeda

File tree

184 files changed

+16763
-11388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+16763
-11388
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ target/
6767

6868
# OS X
6969
.DS_Store
70+
/.mypy_cache
71+
.pyre
72+
/.vscode
73+
/type_info.json

.travis.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@ sudo: false
33
python:
44
- 2.7
55
# - "pypy-5.3.1"
6-
before_install:
7-
- |
8-
if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
9-
export PYENV_ROOT="$HOME/.pyenv"
10-
if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
11-
cd "$PYENV_ROOT" && git pull
12-
else
13-
rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
14-
fi
15-
export PYPY_VERSION="4.0.1"
16-
"$PYENV_ROOT/bin/pyenv" install "pypy-$PYPY_VERSION"
17-
virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
18-
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
19-
fi
206
install:
217
- pip install -e .[test]
228
- pip install flake8
@@ -33,10 +19,12 @@ matrix:
3319
script:
3420
- py.test --cov=graphql graphql tests tests_py35
3521
- python: '3.6'
36-
after_install:
37-
- pip install pytest-asyncio
22+
install:
23+
- pip install -e .[test]
24+
- pip install pytest-asyncio mypy
3825
script:
3926
- py.test --cov=graphql graphql tests tests_py35
27+
- mypy graphql --ignore-missing-imports
4028
- python: '2.7'
4129

4230
deploy:

conftest.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Configuration for pytest to automatically collect types.
2+
# Thanks to Guilherme Salgado.
3+
import pytest
4+
5+
try:
6+
import pyannotate_runtime
7+
PYANOTATE_PRESENT = True
8+
except ImportError:
9+
PYANOTATE_PRESENT = False
10+
11+
if PYANOTATE_PRESENT:
12+
def pytest_collection_finish(session):
13+
"""Handle the pytest collection finish hook: configure pyannotate.
14+
Explicitly delay importing `collect_types` until all tests have
15+
been collected. This gives gevent a chance to monkey patch the
16+
world before importing pyannotate.
17+
"""
18+
from pyannotate_runtime import collect_types
19+
collect_types.init_types_collection()
20+
21+
@pytest.fixture(autouse=True)
22+
def collect_types_fixture():
23+
from pyannotate_runtime import collect_types
24+
collect_types.resume()
25+
yield
26+
collect_types.pause()
27+
28+
def pytest_sessionfinish(session, exitstatus):
29+
from pyannotate_runtime import collect_types
30+
collect_types.dump_stats("type_info.json")

0 commit comments

Comments
 (0)