Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0
rev: v6.0.0 # v6.0.0
hooks:
- id: check-json
types: [file] # override `types: [json]`
Expand All @@ -24,43 +24,43 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 91de51aef61c5f2383f03da25604e3d65a8309e0 # v2.21.1
rev: v2.21.1 # v2.21.1
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: 4b2e70d08cb2ccd26d1fba73588de41c7a5d50b7 # v0.25
rev: v0.25 # v0.25
hooks:
- id: validate-pyproject
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: c883505f64b59c3c5c9375191e4ad9f98e727ccd # v1.0.2
rev: v1.0.2 # v1.0.2
hooks:
- id: sphinx-lint
types: [rst]
- repo: https://github.com/pycqa/isort
rev: dac090ce4d9ee313d086e2e89ab1acb8c2664fa1 # 9.0.0a3
rev: 9.0.0a3 # 9.0.0a3
hooks:
- id: isort
additional_dependencies: ["toml"]
entry: isort --profile=black
name: isort (python)
- repo: https://github.com/psf/black-pre-commit-mirror
rev: fa505ab9c3e0fedafe1709fd7ac2b5f8996c670d # 26.3.1
rev: 26.3.1 # 26.3.1
hooks:
- id: black
- repo: https://github.com/tonybaloney/perflint
rev: 22f831509bc7765ce272ad6fcb99398d86a26a52 # 0.8.1
rev: 0.8.1 # 0.8.1
hooks:
- id: perflint
exclude: ^docs/
- repo: https://github.com/adamchainz/blacken-docs
rev: fda77690955e9b63c6687d8806bafd56a526e45f # 1.20.0
rev: 1.20.0 # 1.20.0
hooks:
- id: blacken-docs
args: [--line-length=79]
additional_dependencies:
- black
- repo: https://github.com/codespell-project/codespell
rev: 2ccb47ff45ad361a21071a7eedda4c37e6ae8c5a # v2.4.2
rev: v2.4.2 # v2.4.2
hooks:
- id: codespell
args: [--toml pyproject.toml]
2 changes: 0 additions & 2 deletions docs/data-processing/apis/fastapi/example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Create a file :file:`main.py` with:

from fastapi import FastAPI


app = FastAPI()


Expand Down Expand Up @@ -77,7 +76,6 @@ Now we modify the file ``main.py`` to receive a body from a ``PUT`` request:

from fastapi import FastAPI


app = FastAPI()


Expand Down
4 changes: 3 additions & 1 deletion docs/data-processing/apis/grpc/accounts_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@
_GETACCOUNTSREQUEST.fields_by_name["account"].message_type = _ACCOUNT
_GETACCOUNTSRESULT.fields_by_name["account"].message_type = _ACCOUNT
DESCRIPTOR.message_types_by_name["Account"] = _ACCOUNT
DESCRIPTOR.message_types_by_name["CreateAccountRequest"] = _CREATEACCOUNTREQUEST
DESCRIPTOR.message_types_by_name["CreateAccountRequest"] = (
_CREATEACCOUNTREQUEST
)
DESCRIPTOR.message_types_by_name["CreateAccountResult"] = _CREATEACCOUNTRESULT
DESCRIPTOR.message_types_by_name["GetAccountsRequest"] = _GETACCOUNTSREQUEST
DESCRIPTOR.message_types_by_name["GetAccountsResult"] = _GETACCOUNTSRESULT
Expand Down
9 changes: 7 additions & 2 deletions docs/data-processing/apis/grpc/tests/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def test_create_account(grpc_stub):
request = CreateAccountRequest(account_name=value)
response = grpc_stub.CreateAccount(request)

assert f"{response.account}" == f'account_id: 1{nl}account_name: "test-data"{nl}'
assert (
f"{response.account}"
== f'account_id: 1{nl}account_name: "test-data"{nl}'
)


def test_get_accounts(grpc_stub):
Expand Down Expand Up @@ -64,7 +67,9 @@ def grpc_server(_grpc_server, grpc_addr, my_ssl_key_path, my_ssl_cert_path):
@pytest.fixture(scope="module")
def my_channel_ssl_credentials(my_ssl_cert_path):
# If we're using self-signed certificate it's necessarily to pass root certificate to channel
return grpc.ssl_channel_credentials(root_certificates=my_ssl_cert_path.read_bytes())
return grpc.ssl_channel_credentials(
root_certificates=my_ssl_cert_path.read_bytes()
)


@pytest.fixture(scope="module")
Expand Down
2 changes: 0 additions & 2 deletions docs/data-processing/postgresql/sqlalchemy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Database connection

from sqlalchemy import create_engine


engine = create_engine("postgresql:///example", echo=True)

Data model
Expand All @@ -56,7 +55,6 @@ Data model
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship


Base = declarative_base()


Expand Down
1 change: 0 additions & 1 deletion docs/data-processing/serialisation-formats/toml/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Overview

import toml


config = toml.load("pyproject.toml")

.. seealso::
Expand Down
3 changes: 0 additions & 3 deletions docs/performance/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ We can create sample data with:

from sklearn.datasets import make_blobs


points, labels_true = make_blobs(
n_samples=1000, centers=3, random_state=0, cluster_std=0.60
)
Expand Down Expand Up @@ -133,7 +132,6 @@ algorithm:

from sklearn.cluster import KMeans


KMeans(10).fit_predict(points)

* `dask_ml.cluster.KMeans
Expand All @@ -143,7 +141,6 @@ algorithm:

from dask_ml.cluster import KMeans


KMeans(10).fit(points).predict(points)

The best that could be said against these existing solutions is that they could
Expand Down
4 changes: 3 additions & 1 deletion docs/performance/nb_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def compute_centers(points, labels):
counts[label] += 1
centers[label] = [a + b for a, b in zip(centers[label], point)]

return [[x / count for x in center] for center, count in zip(centers, counts)]
return [
[x / count for x in center] for center, count in zip(centers, counts)
]


def kmeans(points, n_clusters):
Expand Down
4 changes: 3 additions & 1 deletion docs/performance/np_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def compute_centers(points, labels):
counts[label] += 1
centers[label] = [a + b for a, b in zip(centers[label], point)]

return [[x / count for x in center] for center, count in zip(centers, counts)]
return [
[x / count for x in center] for center, count in zip(centers, counts)
]


def kmeans(points, n_clusters):
Expand Down
4 changes: 3 additions & 1 deletion docs/performance/py_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def compute_centers(points, labels):
counts[label] += 1
centers[label] = [a + b for a, b in zip(centers[label], point)]

return [[x / count for x in center] for center, count in zip(centers, counts)]
return [
[x / count for x in center] for center, count in zip(centers, counts)
]


def kmeans(points, n_clusters):
Expand Down
18 changes: 13 additions & 5 deletions docs/productive/qa/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@
chardet_version = None


def check_compatibility(urllib3_version, chardet_version, charset_normalizer_version):
def check_compatibility(
urllib3_version, chardet_version, charset_normalizer_version
):
urllib3_version = urllib3_version.split(".")
assert urllib3_version != ["dev"] # Verify urllib3 isn't installed from git.
assert urllib3_version != [
"dev"
] # Verify urllib3 isn't installed from git.

# Sometimes, urllib3 only reports its version as 16.1.
if len(urllib3_version) == 2:
Expand All @@ -85,7 +89,9 @@ def check_compatibility(urllib3_version, chardet_version, charset_normalizer_ver
# charset_normalizer >= 2.0.0 < 3.0.0
assert (2, 0, 0) <= (major, minor, patch) < (3, 0, 0)
else:
raise Exception("You need either charset_normalizer or chardet installed")
raise Exception(
"You need either charset_normalizer or chardet installed"
)


def _check_cryptography(cryptography_version):
Expand All @@ -96,8 +102,10 @@ def _check_cryptography(cryptography_version):
return

if cryptography_version < [1, 3, 4]:
warning = "Old version of cryptography ({}) may cause slowdown.".format(
cryptography_version
warning = (
"Old version of cryptography ({}) may cause slowdown.".format(
cryptography_version
)
)
warnings.warn(warning, RequestsDependencyWarning)

Expand Down
33 changes: 24 additions & 9 deletions docs/productive/qa/requests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
ProtocolError,
)
from urllib3.exceptions import ProxyError as _ProxyError
from urllib3.exceptions import (
ReadTimeoutError,
ResponseError,
)
from urllib3.exceptions import ReadTimeoutError, ResponseError
from urllib3.exceptions import SSLError as _SSLError
from urllib3.poolmanager import PoolManager, proxy_from_url
from urllib3.response import HTTPResponse
Expand Down Expand Up @@ -81,7 +78,13 @@ def __init__(self):
super(BaseAdapter, self).__init__()

def send(
self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None
self,
request,
stream=False,
timeout=None,
verify=True,
cert=None,
proxies=None,
):
"""Sends PreparedRequest object. Returns Response object.

Expand Down Expand Up @@ -435,12 +438,20 @@ def proxy_headers(self, proxy):
username, password = get_auth_from_url(proxy)

if username:
headers["Proxy-Authorization"] = _basic_auth_str(username, password)
headers["Proxy-Authorization"] = _basic_auth_str(
username, password
)

return headers

def send(
self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None
self,
request,
stream=False,
timeout=None,
verify=True,
cert=None,
proxies=None,
):
"""Sends PreparedRequest object. Returns Response object.

Expand Down Expand Up @@ -474,7 +485,9 @@ def send(
proxies=proxies,
)

chunked = not (request.body is None or "Content-Length" in request.headers)
chunked = not (
request.body is None or "Content-Length" in request.headers
)

if isinstance(timeout, tuple):
try:
Expand Down Expand Up @@ -516,7 +529,9 @@ def send(
low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)

try:
low_conn.putrequest(request.method, url, skip_accept_encoding=True)
low_conn.putrequest(
request.method, url, skip_accept_encoding=True
)

for header, value in request.headers.items():
low_conn.putheader(header, value)
Expand Down
32 changes: 22 additions & 10 deletions docs/productive/qa/requests/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,19 @@ def __ne__(self, other):
return not self == other

def __call__(self, r):
r.headers["Authorization"] = _basic_auth_str(self.username, self.password)
r.headers["Authorization"] = _basic_auth_str(
self.username, self.password
)
return r


class HTTPProxyAuth(HTTPBasicAuth):
"""Attaches HTTP Proxy Authentication to a given Request object."""

def __call__(self, r):
r.headers["Proxy-Authorization"] = _basic_auth_str(self.username, self.password)
r.headers["Proxy-Authorization"] = _basic_auth_str(
self.username, self.password
)
return r


Expand Down Expand Up @@ -220,12 +224,16 @@ def sha512_utf8(x):
self._thread_local.last_nonce = nonce

# XXX should the partial digests be encoded too?
base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' 'response="%s"' % (
self.username,
realm,
nonce,
path,
respdig,
base = (
'username="%s", realm="%s", nonce="%s", uri="%s", '
'response="%s"'
% (
self.username,
realm,
nonce,
path,
respdig,
)
)
if opaque:
base += ', opaque="%s"' % opaque
Expand Down Expand Up @@ -265,7 +273,9 @@ def handle_401(self, r, **kwargs):
if "digest" in s_auth.lower() and self._thread_local.num_401_calls < 2:
self._thread_local.num_401_calls += 1
pat = re.compile(r"digest ", flags=re.IGNORECASE)
self._thread_local.chal = parse_dict_header(pat.sub("", s_auth, count=1))
self._thread_local.chal = parse_dict_header(
pat.sub("", s_auth, count=1)
)

# Consume content and release the original connection
# to allow our new request to reuse the same one.
Expand All @@ -292,7 +302,9 @@ def __call__(self, r):
self.init_per_thread_state()
# If we have a saved nonce, skip the 401
if self._thread_local.last_nonce:
r.headers["Authorization"] = self.build_digest_header(r.method, r.url)
r.headers["Authorization"] = self.build_digest_header(
r.method, r.url
)
try:
self._thread_local.pos = r.body.tell()
except AttributeError:
Expand Down
Loading
Loading