Skip to content

Commit 370e303

Browse files
author
Daniel Gallagher
committed
Merge branch 'master' of github.com:dan98765/graphql-core into middleware_runs_in_passed_in_order
2 parents 9f64828 + 04560ea commit 370e303

File tree

202 files changed

+18896
-12304
lines changed

Some content is hidden

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

202 files changed

+18896
-12304
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

.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: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,26 @@
11
language: python
2-
sudo: false
3-
python:
4-
- 2.7
5-
# - "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
20-
install:
21-
- pip install -e .[test]
22-
- pip install flake8
23-
script:
24-
- flake8
25-
- py.test --cov=graphql graphql tests
26-
after_success:
27-
- coveralls
282
matrix:
293
include:
30-
- python: '3.5'
31-
after_install:
32-
- pip install pytest-asyncio
33-
script:
34-
- py.test --cov=graphql graphql tests tests_py35
35-
- python: '3.6'
36-
after_install:
37-
- pip install pytest-asyncio
38-
script:
39-
- py.test --cov=graphql graphql tests tests_py35
40-
- python: '2.7'
41-
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=pypy
12+
python: pypy-5.7.1
13+
- env: TOXENV=pre-commit
14+
python: 3.6
15+
- env: TOXENV=mypy
16+
python: 3.6
17+
install: pip install coveralls tox
18+
script: tox
19+
after_success: coveralls
20+
cache:
21+
directories:
22+
- $HOME/.cache/pip
23+
- $HOME/.cache/pre-commit
4224
deploy:
4325
provider: pypi
4426
user: syrusakbary

README.md

Lines changed: 24 additions & 7 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,20 +114,37 @@ from graphql.execution.execute import execute
114114
execute(schema, ast, executor=SyncExecutor())
115115
```
116116

117-
### Development
117+
### Contributing
118118

119-
Install development and test dependencies:
119+
After cloning this repo, create a [virtualenv](https://virtualenv.pypa.io/en/stable/) and ensure dependencies are installed by running:
120120

121121
```sh
122+
virtualenv venv
123+
source venv/bin/activate
122124
pip install -e ".[test]"
123125
```
124126

125-
Run test suite:
127+
Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with:
126128

127129
```sh
128-
pytest
130+
py.test PATH/TO/MY/DIR/test_test.py # Single file
131+
py.test PATH/TO/MY/DIR/ # All tests in directory
129132
```
130133

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+
131148
## Main Contributors
132149

133150
* [@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)