Asana / python-asana

Official Python client library for the Asana API v1
MIT License
299 stars 103 forks source link

urlib3 deprecation warning: HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly. #192

Closed MarkhamLee closed 7 months ago

MarkhamLee commented 7 months ago

Description

While using ".get_tasks_for_project" with a purposely incorrect project GID (testing exception handling), I received the following deprecation warning for urllib3:

HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.

More details on the warning are available here from urllib's change log, under the deprecation heading.

This issue appears to come from line 45 of rest.py in the Asana directory.

Expected Behavior: I wouldn't receive a deprecation warning

Environment: OS: Ubuntu 22.04, Kernel 6.5 Python Version: 3.11.5

Suggested Fix: Per the urlib3 docs, it appears that line 45 needs to be changed from:

return self.urllib3_response.getheaders()

to:

self.urllib3_response.headers.get(name, default)

I'd be willing to submit a PR for this issue.

jv-asana commented 7 months ago

Hi @MarkhamLee, thank you for reporting this. I can add this to our todo for our next update.

jv-asana commented 7 months ago

It looks like this fix might be as simple as bumping our code generator version.

I noticed there was a fix for this in swagger-codegen-geneartors: https://github.com/swagger-api/swagger-codegen-generators/commit/53e68c7edf1e6a462bac22d425f2d7695ffb5034

Current swagger-codegen-generators version we are using is 3.0.46 we can upgrade to the latest version to get this fix

MarkhamLee commented 7 months ago

Thanks for the update!

jv-asana commented 7 months ago

@MarkhamLee Fixed in v5.0.5 release. v5.0.4 publish workflow failed so I had to release under v5.0.5

BEFORE (v5.0.3): https://github.com/Asana/python-asana/blob/v5.0.3/asana/rest.py#L43-L45 AFTER: (v5.0.5): https://github.com/Asana/python-asana/blob/v5.0.5/asana/rest.py#L43-L45