2
2
Fork
You've already forked overpass-api-python-wrapper
2

Add user_agent argument #200

Merged
mvexel merged 3 commits from bradh/overpass-api-python-wrapper:0.8.x into 0.8.x 2026年05月14日 16:46:37 +02:00
Contributor
Copy link

Resolves #194

Resolves #194
Add user_agent argument
Some checks failed
Check / check (pull_request) Failing after 35s
39099604e9

Thanks @bradh. Since we're adding a required parameter to the API() constructor, this is a breaking change. There's two ways we can go about this:

  1. release a 0.8.x version with this (meaningful) change - in that case I would want to add a default value to prevent putting a breaking change in a minor version.
  2. Since adding the UA is also in the v1.0 plan, we can decide to punt on it.

I'm fine with either - if you want to take the opportunity to dive a little deeper and do some work on the 1.0 branch - please do! Otherwise, we'll release a 0.8.x version soon with the UA parameter + a default value.

Thanks @bradh. Since we're adding a required parameter to the `API()` constructor, this is a breaking change. There's two ways we can go about this: 1. release a 0.8.x version with this (meaningful) change - in that case I would want to add a default value to prevent putting a breaking change in a minor version. 2. Since adding the UA is also in the v1.0 plan, we can decide to punt on it. I'm fine with either - if you want to take the opportunity to dive a little deeper and do some work on the 1.0 branch - please do! Otherwise, we'll release a 0.8.x version soon with the UA parameter + a default value.

The CI failed because you didn't run ruff lint --fix - you couldn't have known since there no developer docs :/ . I am adding contributor documentation and a pre-commit hook to make this process smoother in the future.

For now - you can run scripts/check to run tests and linter - that will also expose one API instantiation in the test where you forgot to add the UA param (line 216)

The CI failed because you didn't run `ruff lint --fix` - you couldn't have known since there no developer docs :/ . I am adding contributor documentation and a pre-commit hook to make this process smoother in the future. For now - you can run `scripts/check` to run tests and linter - that will also expose one `API` instantiation in the test where you forgot to add the UA param (line 216)
update API to provide default user agent value
Some checks failed
Check / check (pull_request) Has been cancelled
46ec69167f
Also fix formatting
Author
Contributor
Copy link

I should have known that, since it was in the DEVELOPMENT.md, and it looks like I did run it (i.e. its in the bash history). I was just too clueless to realise that it was only telling me ruff should reformat it, not that ruff did reformat it.

I've added the default and fixed the formatting problem.

I should have known that, since it was in the DEVELOPMENT.md, and it looks like I did run it (i.e. its in the bash history). I was just too clueless to realise that it was only telling me ruff should reformat it, not that ruff did reformat it. I've added the default and fixed the formatting problem.
First-time contributor
Copy link

Hey,

I hope it’s not too impolite if I try to piggyback on this PR.

The call to .../status needs to send the User-Agent header now as well. Maybe you could add the headers to the call?

diff --git a/overpass/api.py b/overpass/api.py
index 45796fa..ecfc958 100644
--- a/overpass/api.py
+++ b/overpass/api.py
@@ -248,7 +248,7 @@ class API:
 """
 :returns: dict describing the client's status with the API
 """
- r = requests.get(self.status_url)
+ r = requests.get(self.status_url, proxies=self.proxies, headers=self.headers)
 lines = tuple(r.text.splitlines())
 
 available_re = re.compile(r"\d(?= slots? available)")
Hey, I hope it’s not too impolite if I try to piggyback on this PR. The call to `.../status` needs to send the User-Agent header now as well. Maybe you could add the headers to the call? ```diff diff --git a/overpass/api.py b/overpass/api.py index 45796fa..ecfc958 100644 --- a/overpass/api.py +++ b/overpass/api.py @@ -248,7 +248,7 @@ class API: """ :returns: dict describing the client's status with the API """ - r = requests.get(self.status_url) + r = requests.get(self.status_url, proxies=self.proxies, headers=self.headers) lines = tuple(r.text.splitlines()) available_re = re.compile(r"\d(?= slots? available)") ```
additional user-agent support for status API
All checks were successful
Check / check (pull_request) Successful in 47s
faee884179
Author
Contributor
Copy link

@hfs wrote in #200 (comment):

The call to .../status needs to send the User-Agent header now as well. Maybe you could add the headers to the call?

If we do that, all of the headers (including the response format) will be appended. It'd be a big refactor to change the parsing, so I've just extracted the user agent value and built a new headers dict.

@hfs wrote in https://codeberg.org/mvexel/overpass-api-python-wrapper/pulls/200#issuecomment-14393624: > The call to `.../status` needs to send the User-Agent header now as well. Maybe you could add the headers to the call? If we do that, all of the headers (including the response format) will be appended. It'd be a big refactor to change the parsing, so I've just extracted the user agent value and built a new headers dict.
Author
Contributor
Copy link

@hfs can you check that meets your use case?

@hfs can you check that meets your use case?

Thanks for your contributions @bradh @hfs ! will merge this and publish a new version shortly.

Thanks for your contributions @bradh @hfs ! will merge this and publish a new version shortly.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mvexel/overpass-api-python-wrapper!200
Reference in a new issue
mvexel/overpass-api-python-wrapper
No description provided.
Delete branch "bradh/overpass-api-python-wrapper:0.8.x"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?