Skip to content

Commit

Permalink
Merge pull request #139 from ithaka/chore/modern-configs
Browse files Browse the repository at this point in the history
  • Loading branch information
daneah authored Oct 10, 2024
2 parents 4a59973 + d5baeab commit 52dfcc0
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 128 deletions.
133 changes: 133 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,142 @@
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "apiron"
version = "8.0.0"
description = "apiron helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP."
authors = [
{ name = "Ithaka Harbors, Inc.", email = "[email protected]" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: MIT License",
]
license = { file = "LICENSE" }
dynamic = ["readme"]
dependencies = [
"requests>=2.11.1",
"urllib3>=1.26.13",
]

[project.optional-dependencies]
docs = [
"sphinx>=7.2.2",
"sphinx-autobuild>=2021.3.14",
]

[project.urls]
Repository = "https://github.com/ithaka/apiron"
Changelog = "https://github.com/ithaka/apiron/blob/main/CHANGELOG.md"
Documentation = "https://apiron.readthedocs.io"
Issues = "https://github.com/ithaka/apiron/issues"

[tool.setuptools.dynamic]
readme = { file = "README.md", content-type = "text/markdown" }

[tool.setuptools.packages.find]
where = ["src"]
exclude = ["tests*"]

######################
# Tool configuration #
######################

[tool.black]
line-length = 120
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']

[tool.isort]
profile = "black"

[tool.mypy]
python_version = "3.9"
warn_unused_configs = true
show_error_context = true
pretty = true
namespace_packages = true
check_untyped_defs = true

[tool.coverage.run]
branch = true
source = ["apiron"]
omit = [
"tests/*",
]

[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = true

[tool.coverage.paths]
source = [
"src",
".tox/**/site-packages",
]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = ["-ra", "--strict-markers", "--cov"]
xfail_strict = true

[tool.tox]
envlist = ["py39", "py310", "py311", "py312", "py313"]
isolated_build = true

[tool.tox.env_run_base]
package = "wheel"
wheel_build_env = ".pkg"
deps = [
"pytest>=7.0.0",
"pytest-cov>=4.1.0",
"pytest-randomly>=3.15.0",
]
commands = [
["pytest", { replace = "posargs", default = [], extend = true }],
]

[tool.tox.env.docs]
extras = [
"docs",
]
commands = [
["sphinx-build", "-b", "html", "docs", "{envtmpdir}/docs"]
]

[tool.tox.env.lint]
skip_install = true
deps = [
"black",
"isort",
"ruff",
]
commands = [
["ruff", "check", { replace = "posargs", default = ["src", "tests"], extend = true }],
["black", { replace = "posargs", default = ["--check", "--diff", "src", "tests"], extend = true }],
["isort", { replace = "posargs", default = ["--check", "--diff", "src", "tests"], extend = true }],
]

[tool.tox.env.typecheck]
deps = [
{ replace = "ref", of = ["tool", "tox", "env_run_base", "deps"], extend = true },
"mypy",
"typing_extensions",
"types-requests",
"types-urllib3",
]
commands = [
["mypy", { replace = "posargs", default = ["src", "tests"], extend = true }],
]
passenv = ["TERM"]
124 changes: 0 additions & 124 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest
import requests


@pytest.fixture(autouse=True)
def hobble_network(monkeypatch, request):
"""Hobble all network calls made through the requests library"""

if "no_hobble_network" in request.keywords:
return

def hobbled_send(session, request_object, **kwargs):
raise RuntimeError(f"requests hobbled for testing: tried calling {request_object.url}")

monkeypatch.setattr(requests.Session, "send", hobbled_send)
5 changes: 4 additions & 1 deletion tests/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def stub_response(**kwargs):


class TestEndpoint:
def test_call(self, service):
@mock.patch("requests.Session", autospec=True)
def test_call(self, MockSession, service):
mock_session = MockSession()
mock_session.proxies = {}
service.foo = apiron.Endpoint()
service.foo()

Expand Down

0 comments on commit 52dfcc0

Please sign in to comment.