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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change Log

- Verify support for Python 3.14
- Made `raise_for_status` configurable. Thanks, @ofipify.

## 4.2.1 (2025-09-09)

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ lint: ## lint the project
ruff format --check .

format: ## Run code formatting
pyproject-fmt --keep-full-version pyproject.toml
ruff format .
# Configure Ruff not to auto-fix (remove!):
# Ignore unused imports (F401), unused variables (F841), `print` statements (T201), and commented-out code (ERA001).
Expand Down
2 changes: 1 addition & 1 deletion epo_ops/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

log = logging.getLogger(__name__)


def _prepare_part(part):
return "({0})".format(quote(part))

Expand Down Expand Up @@ -107,7 +108,6 @@ def _request(self, callback, url, data=None, **kwargs):
self.reset_env()
return response


def _post_callback(self, url, data, **kwargs):
return requests.post(url, data, **kwargs, timeout=self.timeout)

Expand Down
119 changes: 52 additions & 67 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,111 +1,96 @@
# ==================
# Build system setup
# ==================

[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=42", # At least v42 of setuptools required!
"versioningit",
]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
minversion = "2.0"
addopts = """
-rsfEX -p pytester --strict-markers --verbosity=3
--cov=epo_ops tests --cov-report=term-missing --cov-report=xml
"""
log_level = "DEBUG"
log_cli_level = "DEBUG"
testpaths = ["tests"]
xfail_strict = true
markers = []

[tool.ruff]
line-length = 80

extend-exclude = [ "__init__.py" ]
lint.select = [
# Bandit
"S",
# Bugbear
"B",
# Builtins
"A",
# Bugbear
"B",
"B9",
# comprehensions
"C",
# Pycodestyle
"E",
# eradicate
"ERA",
# flake8-2020
"YTT",
# Pyflakes
"F",
# isort
"I",
# pandas-vet
"PD",
# print
"T20",
# Pycodestyle
"E",
"W",
# Pyflakes
"F",
# return
"RET",
# Bandit
"S",
# from `.flake8` file
"T", # T4
"B9",
"T", # T4
# print
"T20",
"W",
# flake8-2020
"YTT",
]

extend-exclude = ["__init__.py"]

lint.ignore = [
"B905", # B905 `zip()` without an explicit `strict=` parameter
"E203",
"E266",
"E501",
"ERA001", # Found commented-out code
"RET505", # Unnecessary `else` after `return` statement
# "W503", # Unknown rule selector
]

# FIXME: Improve this situation wrt. SQL injection, even it is not be an actual attack vector.
lint.per-file-ignores."*sqlite.py" = [
"S608", # Possible SQL injection vector through string-based query construction
]
lint.per-file-ignores."epo_ops/api.py" = [
"A001", # Variable `range` is shadowing a Python builtin
"A002", # Argument `input` is shadowing a Python builtin
"C408", # Unnecessary `dict` call (rewrite as a literal)
]
lint.per-file-ignores."tests/*" = [
"S101", # Use of `assert` detected
]
lint.per-file-ignores."tests/middlewares/throttle/conftest.py" = [
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
]
# from `.isort.cfg` file
[tool.ruff.lint.isort]
combine-as-imports = true
force-wrap-aliases = true
known-third-party = [
lint.isort.combine-as-imports = true
lint.isort.force-wrap-aliases = true
lint.isort.known-third-party = [
"dateutil",
"dogpile",
"dotenv",
"pytest",
"requests",
"six",
]
split-on-trailing-comma = false

lint.isort.split-on-trailing-comma = false
# from `.flake8` file
[tool.ruff.lint.mccabe]
# Flag errors (`C901`) whenever the complexity level exceeds the configured value.
max-complexity = 7


[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"S101", # Use of `assert` detected
]
"epo_ops/api.py" = [
"A001", # Variable `range` is shadowing a Python builtin
"A002", # Argument `input` is shadowing a Python builtin
"C408", # Unnecessary `dict` call (rewrite as a literal)
]
# FIXME: Improve this situation wrt. SQL injection, even it is not be an actual attack vector.
"*sqlite.py" = [
"S608", # Possible SQL injection vector through string-based query construction
]
"tests/middlewares/throttle/conftest.py" = [
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
]
lint.mccabe.max-complexity = 7

[tool.pytest]
ini_options.minversion = "2.0"
ini_options.addopts = """
-rsfEX -p pytester --strict-markers --verbosity=3
--cov=epo_ops tests --cov-report=term-missing --cov-report=xml
"""
ini_options.log_level = "DEBUG"
ini_options.log_cli_level = "DEBUG"
ini_options.testpaths = [ "tests" ]
ini_options.xfail_strict = true
ini_options.markers = []

[tool.versioningit]

[tool.versioningit.vcs]
method = "git"
default-tag = "0.0.0"
vcs.method = "git-archive"
vcs.default-tag = "v0.0.0"
vcs.describe-subst = "$Format:%(describe:tags,match=v*)$"
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import codecs
from os import path

from setuptools import setup
from setuptools import find_packages, setup
from versioningit import get_cmdclasses

here = path.abspath(path.dirname(__file__))
Expand All @@ -15,6 +15,7 @@
description=(
"Python client for EPO OPS, the European Patent Office's Open Patent Services API."
),
license="Apache-2.0",
long_description_content_type="text/markdown",
long_description=readme,
author="George Song",
Expand All @@ -23,8 +24,9 @@
maintainer_email="andreas.motl@ip-tools.org",
url="https://github.com/ip-tools/python-epo-ops-client",
download_url="https://pypi.org/project/python-epo-ops-client/#files",
packages=["epo_ops", "epo_ops.middlewares"],
package_dir={"epo_ops": "epo_ops"},
packages=find_packages(
include=["epo_ops*"],
),
include_package_data=True,
install_requires=[
"dogpile.cache<1.6",
Expand All @@ -35,6 +37,7 @@
],
extras_require={
"develop": [
"pyproject-fmt<3",
"ruff<0.16; python_version >= '3.7'",
"twine<7",
"wheel<1",
Expand All @@ -52,7 +55,6 @@
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
Expand Down
2 changes: 2 additions & 0 deletions tests/helpers/api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ def assert_image_success(client):
assert_request_success(response)
return response


def assert_legal_success(client):
response = client.legal(*data)
assert_request_success(response)
assert "ops:legal" in response.text
return response


def assert_published_data_success(client):
response = client.published_data(*data)
assert_request_success(response)
Expand Down