Skip to content

Commit

Permalink
Merge branch 'master' into origin/fix-enums
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary authored Jul 19, 2018
2 parents 5878bfe + e2151f9 commit 3efd6d1
Show file tree
Hide file tree
Showing 206 changed files with 20,562 additions and 11,932 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ htmlcov/
nosetests.xml
coverage.xml
*,cover
.pytest_cache/

# Translations
*.mo
Expand All @@ -66,3 +67,7 @@ target/

# OS X
.DS_Store
/.mypy_cache
.pyre
/.vscode
/type_info.json
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v1.3.0
hooks:
- id: check-json
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: ^docs/.*$
- id: trailing-whitespace
exclude: README.md
- id: pretty-format-json
args:
- --autofix
- repo: https://github.com/asottile/pyupgrade
rev: v1.4.0
hooks:
- id: pyupgrade
- repo: https://github.com/ambv/black
rev: 18.6b4
hooks:
- id: black
language_version: python3.6
58 changes: 22 additions & 36 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
language: python
sudo: false
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
before_install:
- |
if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then
export PYENV_ROOT="$HOME/.pyenv"
if [ -f "$PYENV_ROOT/bin/pyenv" ]; then
cd "$PYENV_ROOT" && git pull
else
rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
fi
export PYPY_VERSION="4.0.1"
"$PYENV_ROOT/bin/pyenv" install "pypy-$PYPY_VERSION"
virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
fi
install:
- pip install -e .[test]
script:
- py.test --cov=graphql graphql tests
after_success:
- coveralls
matrix:
include:
- python: '3.5'
after_install:
- pip install pytest-asyncio
script:
- py.test --cov=graphql graphql tests tests_py35
- python: '2.7'
install: pip install flake8
script:
- flake8
- env: TOXENV=py27
- env: TOXENV=py34
python: 3.4
- env: TOXENV=py35
python: 3.5
- env: TOXENV=py36
python: 3.6
# - env: TOXENV=py37
# python: 3.7
- env: TOXENV=pypy
python: pypy-5.7.1
- env: TOXENV=pre-commit
python: 3.6
- env: TOXENV=mypy
python: 3.6
install: pip install coveralls tox
script: tox
after_success: coveralls
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/pre-commit
deploy:
provider: pypi
user: syrusakbary
Expand Down
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ For questions, ask [Stack Overflow](http://stackoverflow.com/questions/tagged/gr

## Getting Started

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

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

### Using graphql-core

Expand Down Expand Up @@ -114,6 +114,37 @@ from graphql.execution.execute import execute
execute(schema, ast, executor=SyncExecutor())
```

### Contributing

After cloning this repo, create a [virtualenv](https://virtualenv.pypa.io/en/stable/) and ensure dependencies are installed by running:

```sh
virtualenv venv
source venv/bin/activate
pip install -e ".[test]"
```

Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with:

```sh
py.test PATH/TO/MY/DIR/test_test.py # Single file
py.test PATH/TO/MY/DIR/ # All tests in directory
```

Add the `-s` flag if you have introduced breakpoints into the code for debugging.
Add the `-v` ("verbose") flag to get more detailed test output. For even more detailed output, use `-vv`.
Check out the [pytest documentation](https://docs.pytest.org/en/latest/) for more options and test running controls.

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:
```sh
tox
```
If you wish to run against a specific version defined in the `tox.ini` file:
```sh
tox -e py36
```
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!

## Main Contributors

* [@syrusakbary](https://github.com/syrusakbary/)
Expand Down
35 changes: 35 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Configuration for pytest to automatically collect types.
# Thanks to Guilherme Salgado.
import pytest

try:
import pyannotate_runtime

PYANOTATE_PRESENT = True
except ImportError:
PYANOTATE_PRESENT = False

if PYANOTATE_PRESENT:

def pytest_collection_finish(session):
"""Handle the pytest collection finish hook: configure pyannotate.
Explicitly delay importing `collect_types` until all tests have
been collected. This gives gevent a chance to monkey patch the
world before importing pyannotate.
"""
from pyannotate_runtime import collect_types

collect_types.init_types_collection()

@pytest.fixture(autouse=True)
def collect_types_fixture():
from pyannotate_runtime import collect_types

collect_types.resume()
yield
collect_types.pause()

def pytest_sessionfinish(session, exitstatus):
from pyannotate_runtime import collect_types

collect_types.dump_stats("type_info.json")
Loading

0 comments on commit 3efd6d1

Please sign in to comment.