Skip to content
Myr

Use nox for automation and CI (#128)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Seth Michael Larson · committed by GitHub · parent 95dad24 · Browse files · 16 files+138 added−100 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

16 files+138 added−100 removed

  • tests:+1 added−2 removed
  • other:+137 added−98 removed

16 files+138 added−100 removed

modified:httpx/__init__.py+2 added
84 unmodified lines
85 "SSLConfig",86 "TimeoutConfig",87 "VerifyTypes",88 "HTTPConnection",89 "BasePoolSemaphore",90 "BaseBackgroundManager",91 "ConnectionPool",92 "ConnectTimeout",93 "CookieConflict",94 "DecodingError",
41 unmodified lines
modified:httpx/exceptions.py+6 added-3 removed
1from typing import TYPE_CHECKING1import typing23if TYPE_CHECKING:3if typing.TYPE_CHECKING:4 from .models import BaseRequest, BaseResponse # pragma: nocover567class HTTPError(Exception):
1 unmodified line
9 Base class for Httpx exception10 """1112 def __init__(13 self, request: "BaseRequest" = None, response: "BaseResponse" = None, *args13 self,14 *args: typing.Any,15 request: "BaseRequest" = None,16 response: "BaseResponse" = None,17 ) -> None:18 self.response = response19 self.request = request or getattr(self.response, "request", None)20 super().__init__(*args)
124 unmodified lines
modified:httpx/interfaces.py+2 added-2 removed
39 unmodified lines
40 params: QueryParamTypes = None,41 headers: HeaderTypes = None,42 verify: VerifyTypes = None,43 cert: CertTypes = None,44 timeout: TimeoutTypes = None44 timeout: TimeoutTypes = None,45 ) -> AsyncResponse:46 request = AsyncRequest(method, url, data=data, params=params, headers=headers)47 return await self.send(request, verify=verify, cert=cert, timeout=timeout)48
39 unmodified lines
88 params: QueryParamTypes = None,89 headers: HeaderTypes = None,90 verify: VerifyTypes = None,91 cert: CertTypes = None,92 timeout: TimeoutTypes = None92 timeout: TimeoutTypes = None,93 ) -> Response:94 request = Request(method, url, data=data, params=params, headers=headers)95 return self.send(request, verify=verify, cert=cert, timeout=timeout)96
134 unmodified lines
modified:httpx/models.py+13 added-3 removed
34 unmodified lines
35 normalize_header_value,36 str_query_param,37)3839PrimitiveData = typing.Union[str, int, float, bool, type(None)]39PrimitiveData = typing.Optional[typing.Union[str, int, float, bool]]4041URLTypes = typing.Union["URL", str]4243QueryParamTypes = typing.Union[
47 unmodified lines
91 self._uri_reference = rfc3986.api.iri_reference(url).encode()92 else:93 self._uri_reference = url._uri_reference9495 # Handle IDNA domain names.96 if self._uri_reference.authority:97 idna_authority = self._uri_reference.authority.encode("idna").decode(98 "ascii"99 )100 if idna_authority != self._uri_reference.authority:101 self._uri_reference = self._uri_reference.copy_with(102 authority=idna_authority103 )104105 # Normalize scheme and domain name.106 if self.is_absolute_url:107 self._uri_reference = self._uri_reference.normalize()108
70 unmodified lines
179 # We don't use `.is_absolute` from `rfc3986` because it treats180 # URLs with a fragment portion as not absolute.181 # What we actually care about is if the URL provides182 # a scheme and hostname to which connections should be made.173 return self.scheme and self.host183 return bool(self.scheme and self.host)184185 @property186 def is_relative_url(self) -> bool:187 return not self.is_absolute_url
73 unmodified lines
261 items = parse_qsl(value)262 elif isinstance(value, QueryParams):263 items = value.multi_items()264 elif isinstance(value, list):255 items = value265 items = value # type: ignore266 else:267 items = value.items() # type: ignore268269 self._list = [(str(k), str_query_param(v)) for k, v in items]
913 unmodified lines
modified:httpx/utils.py+2 added-2 removed
21 unmodified lines
22 return value23 return value.encode(encoding or "ascii")242526def str_query_param(value: typing.Union[str, int, float, bool, type(None)]) -> str:26def str_query_param(value: typing.Optional[typing.Union[str, int, float, bool]]) -> str:27 """28 Coerce a primitive data type into a string value for query params.2930 Note that we prefer JSON-style 'true'/'false' for boolean values here.
68 unmodified lines
99100 if netrc_path is None:101 return None102103 netrc_info = netrc.netrc(netrc_path)103 netrc_info = netrc.netrc(str(netrc_path))104 return netrc_info.authenticators(host) # type: ignore
deleted:scripts/install-24 removed
1#!/bin/sh -e23# Use the Python executable provided from the `-p` option, or a default.4[[ $1 = "-p" ]] && PYTHON=$2 || PYTHON="python3"56MIN_VERSION="(3, 6)"7VERSION_OK=`"$PYTHON" -c "import sys; print(sys.version_info[0:2] >= $MIN_VERSION and '1' or '');"`89if [[ -z "$VERSION_OK" ]] ; then10 PYTHON_VERSION=`"$PYTHON" -c "import sys; print('%s.%s' % sys.version_info[0:2]);"`11 DISP_MIN_VERSION=`"$PYTHON" -c "print('%s.%s' % $MIN_VERSION)"`12 echo "ERROR: Python $PYTHON_VERSION detected, but $DISP_MIN_VERSION+ is required."13 echo "Please upgrade your Python distribution to install Databases."14 exit 115fi1617REQUIREMENTS="requirements.txt"18VENV="venv"19PIP="$VENV/bin/pip"2021set -x22"$PYTHON" -m venv "$VENV"23"$PIP" install -r "$REQUIREMENTS"24"$PIP" install -e .
deleted:scripts/lint-16 removed
1#!/bin/sh -e23export PREFIX=""4if [ -d 'venv' ] ; then5 export PREFIX="venv/bin/"6fi78set -x910${PREFIX}autoflake --in-place --recursive httpx tests setup.py11${PREFIX}isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --combine-as --line-width 88 --recursive --apply httpx tests setup.py12${PREFIX}black httpx tests setup.py13${PREFIX}flake8 --max-line-length=88 --ignore=W503,E203,B305 httpx tests setup.py14${PREFIX}mypy httpx --ignore-missing-imports --disallow-untyped-defs1516scripts/clean
deleted:scripts/test-12 removed
1#!/bin/sh -e23export PACKAGE="httpx"4export PREFIX=""5if [ -d 'venv' ] ; then6 export PREFIX="venv/bin/"7fi89set -x1011PYTHONPATH=. ${PREFIX}pytest --ignore venv --cov tests --cov ${PACKAGE} --cov-report= ${@}12${PREFIX}coverage report --show-missing --fail-under=100
modified:tests/models/test_url.py-1 removed
1import pytest2import rfc398623from httpx import URL4from httpx.exceptions import InvalidURL5
172 unmodified lines
modified:tests/test_utils.py+1 added-1 removed
35 unmodified lines
36 ("utf-32-le", "utf-32"),37 ),38)39def test_guess_by_bom(encoding, expected):40 data = u"\ufeff{}".encode(encoding)40 data = "\ufeff{}".encode(encoding)41 assert guess_json_utf(data) == expected424344def test_bad_get_netrc_login():
16 unmodified lines
modified:.gitignore+1 added
4 unmodified lines
5__pycache__/6htmlcov/7*.egg-info/8venv/9.nox
added:.isort.cfg+3 added
1[settings]2known_first_party = httpx3known_third_party = brotli,certifi,chardet,cryptography,h11,h2,hstspreload,nox,pytest,rfc3986,setuptools,trustme,uvicorn
modified:.travis.yml+26 added-7 removed
2 unmodified lines
3language: python45cache: pip67python:8 - "3.6"9 - "3.7"7branches:8 only:9 - master1011matrix:12 include:13 - python: 3.714 env: NOX_SESSION=check15 - python: 3.716 env: NOX_SESSION=docs1718 - python: 3.619 env: NOX_SESSION=test-3.620 - python: 3.721 env: NOX_SESSION=test-3.722 - python: 3.8-dev23 env: NOX_SESSION=test-3.82425 allow_failures:26 - python: 3.8-dev2728install:12 - pip install -U -r requirements.txt29 - pip install --upgrade nox3031script:15 - scripts/test32 - nox -s ${NOX_SESSION}3334after_script:18 - pip install codecov19 - codecov35 - if [ -f .coverage ]; then36 python -m pip install codecov;37 codecov;38 fi
added:noxfile.py+60 added
1import nox23source_files = ("httpx", "tests", "setup.py", "noxfile.py")456@nox.session(reuse_venv=True)7def lint(session):8 session.install("autoflake", "black", "flake8", "isort", "seed-isort-config")910 session.run("autoflake", "--in-place", "--recursive", *source_files)11 session.run("seed-isort-config", "--application-directories=httpx")12 session.run(13 "isort",14 "--project=httpx",15 "--multi-line=3",16 "--trailing-comma",17 "--force-grid-wrap=0",18 "--combine-as",19 "--line-width=88",20 "--recursive",21 "--apply",22 *source_files,23 )24 session.run("black", "--target-version=py36", *source_files)2526 check(session)272829@nox.session(reuse_venv=True)30def check(session):31 session.install("black", "flake8", "flake8-bugbear", "mypy")3233 session.run("black", "--check", "--target-version=py36", *source_files)34 session.run(35 "flake8", "--max-line-length=88", "--ignore=W503,E203,B305", *source_files36 )37 session.run("mypy", "httpx", "--ignore-missing-imports", "--disallow-untyped-defs")383940@nox.session(reuse_venv=True)41def docs(session):42 session.install("mkdocs", "mkdocs-material")4344 session.run("mkdocs", "build")454647@nox.session(python=["3.6", "3.7", "3.8"])48def test(session):49 session.install("-r", "test-requirements.txt")5051 session.run(52 "coverage",53 "run",54 "--omit='*'",55 "-m",56 "pytest",57 "--cov=httpx",58 "--cov=tests",59 "--cov-report=term-missing",60 )
deleted:requirements.txt-29 removed
1certifi2chardet==3.*3h11==0.8.*4h2==3.*5hstspreload6idna==2.*7rfc3986==1.*89# Optional10brotlipy==0.7.*1112# Documentation13mkdocs14mkdocs-material1516# Testing17autoflake18black19cryptography20flake821flake8-bugbear22flake8-comprehensions23isort24mypy25pytest26pytest-asyncio27pytest-cov28trustme29uvicorn
added:test-requirements.txt+22 added
1certifi2chardet==3.*3h11==0.8.*4h2==3.*5hstspreload6idna==2.*7rfc3986==1.*89# Optional10brotlipy==0.7.*1112cryptography13flake814flake8-bugbear15flake8-comprehensions16isort17mypy18pytest19pytest-asyncio20pytest-cov21trustme22uvicorn