Skip to content

Commit a55c796

Browse files
committed
Merge remote-tracking branch 'github/master' into logging-2
2 parents 274bb4f + 9202021 commit a55c796

File tree

207 files changed

+20113
-12406
lines changed

Some content is hidden

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

207 files changed

+20113
-12406
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 & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
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=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
4226
deploy:
4327
provider: pypi
4428
user: syrusakbary

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ global-exclude tests/*
22
recursive-exclude tests *
33
recursive-exclude tests_py35 *
44
include LICENSE
5+
include README.md

README.md

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
GraphQL for Python.
44

5-
*This library is a port of [graphql-js](https://github.com/graphql/graphql-js) to Python and currently is up-to-date with release [0.6.0](https://github.com/graphql/graphql-js/releases/tag/v0.6.0).*
6-
5+
_This library is a port of [graphql-js](https://github.com/graphql/graphql-js) to Python and currently is up-to-date with release [0.6.0](https://github.com/graphql/graphql-js/releases/tag/v0.6.0)._
76

87
[![PyPI version](https://badge.fury.io/py/graphql-core.svg)](https://badge.fury.io/py/graphql-core)
98
[![Build Status](https://travis-ci.org/graphql-python/graphql-core.svg?branch=master)](https://travis-ci.org/graphql-python/graphql-core)
@@ -17,13 +16,13 @@ For questions, ask [Stack Overflow](http://stackoverflow.com/questions/tagged/gr
1716

1817
## Getting Started
1918

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

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

2827
### Using graphql-core
2928

@@ -98,11 +97,11 @@ print result.errors
9897
The graphql query is executed, by default, synchronously (using `SyncExecutor`).
9998
However the following executors are available if we want to resolve our fields in parallel:
10099

101-
* `graphql.execution.executors.asyncio.AsyncioExecutor`: This executor executes the resolvers in the Python asyncio event loop.
102-
* `graphql.execution.executors.gevent.GeventExecutor`: This executor executes the resolvers in the Gevent event loop.
103-
* `graphql.execution.executors.process.ProcessExecutor`: This executor executes each resolver as a process.
104-
* `graphql.execution.executors.thread.ThreadExecutor`: This executor executes each resolver in a Thread.
105-
* `graphql.execution.executors.sync.SyncExecutor`: This executor executes each resolver synchronusly (default).
100+
- `graphql.execution.executors.asyncio.AsyncioExecutor`: This executor executes the resolvers in the Python asyncio event loop.
101+
- `graphql.execution.executors.gevent.GeventExecutor`: This executor executes the resolvers in the Gevent event loop.
102+
- `graphql.execution.executors.process.ProcessExecutor`: This executor executes each resolver as a process.
103+
- `graphql.execution.executors.thread.ThreadExecutor`: This executor executes each resolver in a Thread.
104+
- `graphql.execution.executors.sync.SyncExecutor`: This executor executes each resolver synchronusly (default).
106105

107106
#### Usage
108107

@@ -114,11 +113,46 @@ from graphql.execution.execute import execute
114113
execute(schema, ast, executor=SyncExecutor())
115114
```
116115

116+
### Contributing
117+
118+
After cloning this repo, create a [virtualenv](https://virtualenv.pypa.io/en/stable/) and ensure dependencies are installed by running:
119+
120+
```sh
121+
virtualenv venv
122+
source venv/bin/activate
123+
pip install -e ".[test]"
124+
```
125+
126+
Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with:
127+
128+
```sh
129+
py.test PATH/TO/MY/DIR/test_test.py # Single file
130+
py.test PATH/TO/MY/DIR/ # All tests in directory
131+
```
132+
133+
Add the `-s` flag if you have introduced breakpoints into the code for debugging.
134+
Add the `-v` ("verbose") flag to get more detailed test output. For even more detailed output, use `-vv`.
135+
Check out the [pytest documentation](https://docs.pytest.org/en/latest/) for more options and test running controls.
136+
137+
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:
138+
139+
```sh
140+
tox
141+
```
142+
143+
If you wish to run against a specific version defined in the `tox.ini` file:
144+
145+
```sh
146+
tox -e py36
147+
```
148+
149+
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!
150+
117151
## Main Contributors
118152

119-
* [@syrusakbary](https://github.com/syrusakbary/)
120-
* [@jhgg](https://github.com/jhgg/)
121-
* [@dittos](https://github.com/dittos/)
153+
- [@syrusakbary](https://github.com/syrusakbary/)
154+
- [@jhgg](https://github.com/jhgg/)
155+
- [@dittos](https://github.com/dittos/)
122156

123157
## License
124158

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)