Skip to content

Commit 3efd6d1

Browse files
authored
Merge branch 'master' into origin/fix-enums
2 parents 5878bfe + e2151f9 commit 3efd6d1

File tree

206 files changed

+20562
-11932
lines changed

Some content is hidden

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

206 files changed

+20562
-11932
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ htmlcov/
4646
nosetests.xml
4747
coverage.xml
4848
*,cover
49+
.pytest_cache/
4950

5051
# Translations
5152
*.mo
@@ -66,3 +67,7 @@ target/
6667

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

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: git://github.com/pre-commit/pre-commit-hooks
3+
rev: v1.3.0
4+
hooks:
5+
- id: check-json
6+
- id: check-yaml
7+
- id: debug-statements
8+
- id: end-of-file-fixer
9+
exclude: ^docs/.*$
10+
- id: trailing-whitespace
11+
exclude: README.md
12+
- id: pretty-format-json
13+
args:
14+
- --autofix
15+
- repo: https://github.com/asottile/pyupgrade
16+
rev: v1.4.0
17+
hooks:
18+
- id: pyupgrade
19+
- repo: https://github.com/ambv/black
20+
rev: 18.6b4
21+
hooks:
22+
- id: black
23+
language_version: python3.6

.travis.yml

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
language: python
2-
sudo: false
3-
python:
4-
- 2.7
5-
- 3.4
6-
- 3.5
7-
- 3.6
8-
- pypy
9-
before_install:
10-
- |
11-
if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
12-
export PYENV_ROOT="$HOME/.pyenv"
13-
if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
14-
cd "$PYENV_ROOT" && git pull
15-
else
16-
rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
17-
fi
18-
export PYPY_VERSION="4.0.1"
19-
"$PYENV_ROOT/bin/pyenv" install "pypy-$PYPY_VERSION"
20-
virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
21-
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
22-
fi
23-
install:
24-
- pip install -e .[test]
25-
script:
26-
- py.test --cov=graphql graphql tests
27-
after_success:
28-
- coveralls
292
matrix:
303
include:
31-
- python: '3.5'
32-
after_install:
33-
- pip install pytest-asyncio
34-
script:
35-
- py.test --cov=graphql graphql tests tests_py35
36-
- python: '2.7'
37-
install: pip install flake8
38-
script:
39-
- flake8
4+
- env: TOXENV=py27
5+
- env: TOXENV=py34
6+
python: 3.4
7+
- env: TOXENV=py35
8+
python: 3.5
9+
- env: TOXENV=py36
10+
python: 3.6
11+
# - env: TOXENV=py37
12+
# python: 3.7
13+
- env: TOXENV=pypy
14+
python: pypy-5.7.1
15+
- env: TOXENV=pre-commit
16+
python: 3.6
17+
- env: TOXENV=mypy
18+
python: 3.6
19+
install: pip install coveralls tox
20+
script: tox
21+
after_success: coveralls
22+
cache:
23+
directories:
24+
- $HOME/.cache/pip
25+
- $HOME/.cache/pre-commit
4026
deploy:
4127
provider: pypi
4228
user: syrusakbary

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ For questions, ask [Stack Overflow](http://stackoverflow.com/questions/tagged/gr
1717

1818
## Getting Started
1919

20-
An overview of the GraphQL language is available in the
20+
An overview of the GraphQL language is available in the
2121
[README](https://github.com/facebook/graphql/blob/master/README.md) for the
22-
[Specification for GraphQL](https://github.com/facebook/graphql).
22+
[Specification for GraphQL](https://github.com/facebook/graphql).
2323

2424
The overview describes a simple set of GraphQL examples that exist as [tests](https://github.com/graphql-python/graphql-core/tree/master/tests/)
2525
in this repository. A good way to get started is to walk through that README and the corresponding tests
26-
in parallel.
26+
in parallel.
2727

2828
### Using graphql-core
2929

@@ -114,6 +114,37 @@ from graphql.execution.execute import execute
114114
execute(schema, ast, executor=SyncExecutor())
115115
```
116116

117+
### Contributing
118+
119+
After cloning this repo, create a [virtualenv](https://virtualenv.pypa.io/en/stable/) and ensure dependencies are installed by running:
120+
121+
```sh
122+
virtualenv venv
123+
source venv/bin/activate
124+
pip install -e ".[test]"
125+
```
126+
127+
Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with:
128+
129+
```sh
130+
py.test PATH/TO/MY/DIR/test_test.py # Single file
131+
py.test PATH/TO/MY/DIR/ # All tests in directory
132+
```
133+
134+
Add the `-s` flag if you have introduced breakpoints into the code for debugging.
135+
Add the `-v` ("verbose") flag to get more detailed test output. For even more detailed output, use `-vv`.
136+
Check out the [pytest documentation](https://docs.pytest.org/en/latest/) for more options and test running controls.
137+
138+
GraphQL-core supports several versions of Python. To make sure that changes do not break compatibility with any of those versions, we use `tox` to create virtualenvs for each python version and run tests with that version. To run against all python versions defined in the `tox.ini` config file, just run:
139+
```sh
140+
tox
141+
```
142+
If you wish to run against a specific version defined in the `tox.ini` file:
143+
```sh
144+
tox -e py36
145+
```
146+
Tox can only use whatever versions of python are installed on your system. When you create a pull request, Travis will also be running the same tests and report the results, so there is no need for potential contributors to try to install every single version of python on their own system ahead of time. We appreciate opening issues and pull requests to make GraphQL-core even more stable & useful!
147+
117148
## Main Contributors
118149

119150
* [@syrusakbary](https://github.com/syrusakbary/)

conftest.py

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

0 commit comments

Comments
 (0)