Skip to content

Dealing with new DeprecationWarning about using method_whitelist argument of Retry #2057

@andy-maier

Description

@andy-maier

We are using the method_whitelist init parameter of Retry. Version 1.26.0 of urllib3 introduced a replacement init parameter named allowed_methods and at the same time started issuing a DeprecationWarning for using method_whitelist.

Our tests are set up to fail if unexpected warnings are issued. Also, our package is included in Linux distributions so we are relatively conservative regarding version upgrades of dependent packages such as urllib3. Also, upgrading the minimum version of urllib3 would drive other upgrades: For example, we are using a minimum version of requests 2.20.1 which specifies urllib3>=1.21.1,<1.25.

Therefore, we would like to have a way to figure out whether the allowed_methods argument is already supported or not. Since this is a change to the init method, it is difficult to react to that change in user code. For example, one could check if the Retry object has an attribute named allowed_methods but for that the object first needs to have been created.

One way to check this seems to be to verify the urllib3 package version which I would rather try to avoid if possible.

Another solution would be to suppress the DeprecationWarning, but we would not like to do that globally, and catching the warning just for this object creation seems like overkill. Plus, this approach would fail once you remove the old init argument.

Is there a simple way to find out whether Retry supports the allowed_methods init argument?

PS: I have a hard time understanding why you did this change in the first place. Just for a nicer name? From one of your user's perspective, this was definitely not worth it. Just my 2 cents on that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions