Skip to content

Commit dde31e9

Browse files
authored
Merge pull request #36 from docentYT/development
v3.1.0
2 parents 0622bdf + 3821077 commit dde31e9

File tree

13 files changed

+94
-39
lines changed

13 files changed

+94
-39
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [ubuntu-latest, windows-latest]
19-
python-version: ['3.10', '3.11', '3.12', '3.13']
19+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
2020

2121
steps:
2222
- uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.1.0] - 2025-10-08
9+
10+
### Added
11+
- Additional tests for `api._request()`
12+
- Support for python 3.14
13+
14+
### Changed
15+
- Exceptions for `notes.get_bbox()` (400 ValueError), `changeset.get_query()` (400 ValueError) and `changeset.upload()` (409 ChangesetAlreadyClosedOrUserIsNotAnAuthor) now will contain additional text returned by osm api [#35](https://github.com/docentYT/osm_easy_api/issues/35)
16+
- Use genbadge instead of coverage-badge
17+
18+
### Fixed
19+
- Dependencies update
20+
821
## [3.0.2] - 2025-06-19
922
### Added
1023
- Support for python 3.13

coverage-badge.svg

Lines changed: 1 addition & 21 deletions
Loading

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
requests==2.32.4
1+
requests==2.32.5

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ classifiers =
2727
Programming Language :: Python :: 3.11
2828
Programming Language :: Python :: 3.12
2929
Programming Language :: Python :: 3.13
30+
Programming Language :: Python :: 3.14
3031

3132
[options]
3233
packages = find:

src/osm_easy_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Python package for parsing osm diffs and communicating with the OpenStreetMap api."""
2-
VERSION = "3.0.2"
2+
VERSION = "3.1.0"
33

44
from . import data_classes
55
from . import diff

src/osm_easy_api/api/api.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ def __init__(self, url: str = "https://master.apis.dev.openstreetmap.org", acces
3939
self._headers.update({"User-Agent": user_agent})
4040

4141
def _request(self, method: _RequestMethods, url: str, stream: bool = False, files: dict | None = None, custom_status_code_exceptions: dict = {int: Exception}, body = None) -> "Response":
42+
"""Sends an HTTP request and handles response status codes.
43+
44+
Args:
45+
method (_RequestMethods): The HTTP method to use (e.g. GET, POST).
46+
url (str): The URL to send the request to.
47+
stream (bool, optional): Whether to stream the response content. Defaults to False.
48+
files (dict | None, optional): Files to include in the request. Defaults to None.
49+
custom_status_code_exceptions (dict, optional): A mapping of status codes to exception types
50+
used to override default behavior. Provide `-1` code to raise for all not listed status codes.
51+
body (Any, optional): The body of the request. If provided, it will be encoded in UTF-8.
52+
53+
Returns:
54+
Response: The HTTP response object if the request was successful (status code 200).
55+
56+
Raises:
57+
ValueError: If a mapped exception type is set and contains a string template.
58+
NotImplementedError: If the status code is unexpected and no mapped exception is found.
59+
Exception: If the status code matches a mapped exception in the provided or default dictionary.
60+
61+
Notes:
62+
The method uses `self._headers` for all requests.
63+
Exceptions may include response content and status code via string formatting.
64+
"""
4265
response = requests.request(str(method), url, stream=stream, files=files, data=body.encode('utf-8') if body else None, headers=self._headers)
4366
if response.status_code == 200: return response
4467

src/osm_easy_api/api/endpoints/changeset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def get_query(self, left: float | None = None, bottom: float | None = None, righ
152152
generator = self.outer._request_generator(
153153
method=self.outer._RequestMethods.GET,
154154
url=join_url(self.outer._url.changeset["get_query"], param),
155-
custom_status_code_exceptions={400: ValueError("Invalid arguments. See https://wiki.openstreetmap.org/wiki/API_v0.6#Query:_GET_/api/0.6/changesets for more info.")})
155+
custom_status_code_exceptions={400: ValueError("Invalid arguments: {TEXT}")})
156156

157157
return self._xml_to_changesets_list(generator)
158158

@@ -254,7 +254,7 @@ def upload(self, changeset_id: int, osmChange: OsmChange, make_osmChange_valid:
254254
custom_status_code_exceptions= {
255255
400: exceptions.ErrorWhenParsingXML("{TEXT}"),
256256
404: exceptions.IdNotFoundError("{TEXT}"),
257-
409: exceptions.ChangesetAlreadyClosedOrUserIsNotAnAuthor(),
257+
409: exceptions.ChangesetAlreadyClosedOrUserIsNotAnAuthor("{TEXT}"),
258258
-1: ValueError("Unexpected but correct error. Status code: {CODE}")
259259
}
260260
)

src/osm_easy_api/api/endpoints/notes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def get_bbox(self, left: str, bottom: str, right: str, top: str, limit: int = 10
102102
generator = self.outer._request_generator(
103103
method=self.outer._RequestMethods.GET,
104104
url=url,
105-
custom_status_code_exceptions={400: ValueError("Limits exceeded")}
105+
custom_status_code_exceptions={400: ValueError("Limits exceeded: {TEXT}")}
106106
)
107107

108108
return self._xml_to_notes_list(generator)

test-requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
responses == 0.25.7
2-
tox == 4.27.0
3-
coverage == 7.9.1
4-
coverage-badge == 1.1.1
1+
responses == 0.25.8
2+
tox == 4.30.3
3+
coverage == 7.9.2
4+
genbadge[coverage] == 1.1.2

0 commit comments

Comments
 (0)