Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ lint: ## lint the project
format: ## Run code formatting
# Configure Ruff not to auto-fix (remove!):
# Ignore unused imports (F401), unused variables (F841), `print` statements (T201), and commented-out code (ERA001).
ruff --fix --ignore=ERA --ignore=F401 --ignore=F841 --ignore=T20 --ignore=ERA001 .
ruff check --fix --ignore=ERA --ignore=F401 --ignore=F841 --ignore=T20 --ignore=ERA001 .
black .

test: clean ## Run tests with virtualenv Python
Expand Down
18 changes: 14 additions & 4 deletions epo_ops/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def family(
return self._make_request(url, None, params=input.as_api_input(), use_get=True)

def image(
self, path: str, range: int = 1, document_format: str = "application/tiff"
self,
path: str,
range: int = 1,
document_format: str = "application/tiff",
) -> requests.Response:
"""
Retrieve the image page for a given path, one page at a time.
Expand Down Expand Up @@ -234,7 +237,8 @@ def published_data_search(
range = dict(key="X-OPS-Range", begin=range_begin, end=range_end)
return self._search_request(
dict(
service=self.__published_data_search_path__, constituents=constituents
service=self.__published_data_search_path__,
constituents=constituents,
),
cql,
range,
Expand Down Expand Up @@ -306,7 +310,10 @@ def _acquire_token(self):
}
payload = {"grant_type": "client_credentials"}
response = requests.post(
self.__auth_url__, headers=headers, data=payload, timeout=NETWORK_TIMEOUT
self.__auth_url__,
headers=headers,
data=payload,
timeout=NETWORK_TIMEOUT,
)
response.raise_for_status()
self._access_token = AccessToken(response)
Expand Down Expand Up @@ -401,7 +408,10 @@ def _image_request(self, path, range, document_format):
params = {"Range": range}
data = path.replace(self.__images_path__ + "/", "")
return self._make_request(
url, data=data, extra_headers={"Accept": document_format}, params=params
url,
data=data,
extra_headers={"Accept": document_format},
params=params,
)

def _check_for_expired_token(self, response):
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from codecs import open
import codecs
from os import path

from setuptools import setup
from versioningit import get_cmdclasses

here = path.abspath(path.dirname(__file__))

with open(path.join(here, "README.md"), encoding="utf-8") as f:
with codecs.open(path.join(here, "README.md"), encoding="utf-8") as f:
readme = f.read()

setup(
Expand Down Expand Up @@ -37,7 +37,7 @@
extras_require={
"develop": [
"black<25",
"ruff<0.7; python_version >= '3.7'",
"ruff<0.10; python_version >= '3.7'",
"twine<6",
"wheel<1",
],
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def reset_cached_client(request):

ops_key, ops_secret = get_secrets_or_skip_tests()
return Client(
ops_key, ops_secret, middlewares=[mkcache(request), mkthrottler(request)]
ops_key,
ops_secret,
middlewares=[mkcache(request), mkthrottler(request)],
)


Expand Down
7 changes: 3 additions & 4 deletions tests/middlewares/throttle/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

import codecs
import os
from codecs import open
from datetime import timedelta
from pprint import pformat
from random import choice, shuffle
Expand Down Expand Up @@ -178,7 +177,7 @@ def generate_sample_throttle_snapshot_reprs(throttle_snapshot):
makedirs(sample_path)
fheader = os.path.join(sample_path, "throttle_snapshot.header")
fdict = os.path.join(sample_path, "throttle_snapshot.dict")
with open(fheader, "wb+", encoding="utf-8") as of:
with codecs.open(fheader, "wb+", encoding="utf-8") as of:
of.write(throttle_snapshot.as_header())
with open(fdict, "wb+", encoding="utf-8") as of:
with codecs.open(fdict, "wb+", encoding="utf-8") as of:
of.write(pformat(throttle_snapshot.as_dict()))
5 changes: 4 additions & 1 deletion tests/middlewares/throttle/helpers/conftest_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def __init__(self, system_status, service_statuses):

@property
def base(self):
return {"system_status": "idle", "services": {}} # idle, busy, overloaded
return {
"system_status": "idle",
"services": {},
} # idle, busy, overloaded

def as_header(self):
services = [status.as_header() for status in self.service_statuses]
Expand Down
1 change: 1 addition & 0 deletions tests/secrets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# ruff: noqa: A005 # Module `secrets` shadows a Python standard-library module
from __future__ import (
absolute_import,
division,
Expand Down
Loading