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
Provenance
- Commit
80dc3e2- Tree
7f7cd93- Author
Seth Michael Larson <sethmichaellarson@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
95dad24
16 files changed+138 added−100 removed
modified:httpx/__init__.py+2 added
84 unmodified lines85 "SSLConfig",86 "TimeoutConfig",87 "VerifyTypes",88 "HTTPConnection",89+ "BasePoolSemaphore",90+ "BaseBackgroundManager",91 "ConnectionPool",92 "ConnectTimeout",93 "CookieConflict",94 "DecodingError",41 unmodified linesmodified:httpx/exceptions.py+6 added-3 removed
1-from typing import TYPE_CHECKING1+import typing2 3-if TYPE_CHECKING:3+if typing.TYPE_CHECKING:4 from .models import BaseRequest, BaseResponse # pragma: nocover5 6 7 class HTTPError(Exception):1 unmodified line9 Base class for Httpx exception10 """11 12 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 linesmodified:httpx/interfaces.py+2 added-2 removed
39 unmodified lines40 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 lines88 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 linesmodified:httpx/models.py+13 added-3 removed
34 unmodified lines35 normalize_header_value,36 str_query_param,37 )38 39-PrimitiveData = typing.Union[str, int, float, bool, type(None)]39+PrimitiveData = typing.Optional[typing.Union[str, int, float, bool]]40 41 URLTypes = typing.Union["URL", str]42 43 QueryParamTypes = typing.Union[47 unmodified lines91 self._uri_reference = rfc3986.api.iri_reference(url).encode()92 else:93 self._uri_reference = url._uri_reference94 95+ # 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+ )104+105 # Normalize scheme and domain name.106 if self.is_absolute_url:107 self._uri_reference = self._uri_reference.normalize()108 70 unmodified lines179 # 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)184 185 @property186 def is_relative_url(self) -> bool:187 return not self.is_absolute_url73 unmodified lines261 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: ignore268 269 self._list = [(str(k), str_query_param(v)) for k, v in items]913 unmodified linesmodified:httpx/utils.py+2 added-2 removed
21 unmodified lines22 return value23 return value.encode(encoding or "ascii")24 25 26-def str_query_param(value: typing.Union[str, int, float, bool, type(None)]) -> str:26+def 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.29 30 Note that we prefer JSON-style 'true'/'false' for boolean values here.68 unmodified lines99 100 if netrc_path is None:101 return None102 103- netrc_info = netrc.netrc(netrc_path)103+ netrc_info = netrc.netrc(str(netrc_path))104 return netrc_info.authenticators(host) # type: ignoredeleted:scripts/install-24 removed
1-#!/bin/sh -e2-3-# Use the Python executable provided from the `-p` option, or a default.4-[[ $1 = "-p" ]] && PYTHON=$2 || PYTHON="python3"5-6-MIN_VERSION="(3, 6)"7-VERSION_OK=`"$PYTHON" -c "import sys; print(sys.version_info[0:2] >= $MIN_VERSION and '1' or '');"`8-9-if [[ -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 115-fi16-17-REQUIREMENTS="requirements.txt"18-VENV="venv"19-PIP="$VENV/bin/pip"20-21-set -x22-"$PYTHON" -m venv "$VENV"23-"$PIP" install -r "$REQUIREMENTS"24-"$PIP" install -e .deleted:scripts/lint-16 removed
1-#!/bin/sh -e2-3-export PREFIX=""4-if [ -d 'venv' ] ; then5- export PREFIX="venv/bin/"6-fi7-8-set -x9-10-${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-defs15-16-scripts/cleandeleted:scripts/test-12 removed
1-#!/bin/sh -e2-3-export PACKAGE="httpx"4-export PREFIX=""5-if [ -d 'venv' ] ; then6- export PREFIX="venv/bin/"7-fi8-9-set -x10-11-PYTHONPATH=. ${PREFIX}pytest --ignore venv --cov tests --cov ${PACKAGE} --cov-report= ${@}12-${PREFIX}coverage report --show-missing --fail-under=100modified:tests/models/test_url.py-1 removed
1 import pytest2-import rfc39862 3 from httpx import URL4 from httpx.exceptions import InvalidURL5 172 unmodified linesmodified:tests/test_utils.py+1 added-1 removed
35 unmodified lines36 ("utf-32-le", "utf-32"),37 ),38 )39 def test_guess_by_bom(encoding, expected):40- data = u"\ufeff{}".encode(encoding)40+ data = "\ufeff{}".encode(encoding)41 assert guess_json_utf(data) == expected42 43 44 def test_bad_get_netrc_login():16 unmodified linesmodified:.gitignore+1 added
4 unmodified lines5 __pycache__/6 htmlcov/7 *.egg-info/8 venv/9+.noxadded:.isort.cfg+3 added
1+[settings]2+known_first_party = httpx3+known_third_party = brotli,certifi,chardet,cryptography,h11,h2,hstspreload,nox,pytest,rfc3986,setuptools,trustme,uvicornmodified:.travis.yml+26 added-7 removed
2 unmodified lines3 language: python4 5 cache: pip6 7-python:8- - "3.6"9- - "3.7"7+branches:8+ only:9+ - master10 11+matrix:12+ include:13+ - python: 3.714+ env: NOX_SESSION=check15+ - python: 3.716+ env: NOX_SESSION=docs17+18+ - 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.824+25+ allow_failures:26+ - python: 3.8-dev27+28 install:12- - pip install -U -r requirements.txt29+ - pip install --upgrade nox30 31 script:15- - scripts/test32+ - nox -s ${NOX_SESSION}33 34 after_script:18- - pip install codecov19- - codecov35+ - if [ -f .coverage ]; then36+ python -m pip install codecov;37+ codecov;38+ fiadded:noxfile.py+60 added
1+import nox2+3+source_files = ("httpx", "tests", "setup.py", "noxfile.py")4+5+6+@nox.session(reuse_venv=True)7+def lint(session):8+ session.install("autoflake", "black", "flake8", "isort", "seed-isort-config")9+10+ 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)25+26+ check(session)27+28+29+@nox.session(reuse_venv=True)30+def check(session):31+ session.install("black", "flake8", "flake8-bugbear", "mypy")32+33+ 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")38+39+40+@nox.session(reuse_venv=True)41+def docs(session):42+ session.install("mkdocs", "mkdocs-material")43+44+ session.run("mkdocs", "build")45+46+47+@nox.session(python=["3.6", "3.7", "3.8"])48+def test(session):49+ session.install("-r", "test-requirements.txt")50+51+ 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
1-certifi2-chardet==3.*3-h11==0.8.*4-h2==3.*5-hstspreload6-idna==2.*7-rfc3986==1.*8-9-# Optional10-brotlipy==0.7.*11-12-# Documentation13-mkdocs14-mkdocs-material15-16-# Testing17-autoflake18-black19-cryptography20-flake821-flake8-bugbear22-flake8-comprehensions23-isort24-mypy25-pytest26-pytest-asyncio27-pytest-cov28-trustme29-uvicornadded:test-requirements.txt+22 added
1+certifi2+chardet==3.*3+h11==0.8.*4+h2==3.*5+hstspreload6+idna==2.*7+rfc3986==1.*8+9+# Optional10+brotlipy==0.7.*11+12+cryptography13+flake814+flake8-bugbear15+flake8-comprehensions16+isort17+mypy18+pytest19+pytest-asyncio20+pytest-cov21+trustme22+uvicorn