iamkubi / pydactyl

Python wrapper for the Pterodactyl Panel API
MIT License
69 stars 21 forks source link

TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist' #76

Closed Tarkhubal closed 1 year ago

Tarkhubal commented 1 year ago

Describe the bug I have an error and I think it's because of the new version, I had never seen it before

I had the error and my program analyzed by BingAI and it told me this: It seems that this library uses urllib323 to make HTTP requests. As I said before, the method_whitelist argument was renamed to allowed_methods in urllib32 version 1.26.0.

To Reproduce The error :

File "/home/container/.local/lib/python3.11/site-packages/discord/app_commands/commands.py", line 841, in _do_call
     return await self._callback(self.binding, interaction, **params) # type: ignore
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^
   File "/home/container/cogs/manage_server.py", line 111, in servers_stats
     api = PterodactylClient(guild_data["url"], guild_data["PteroAPIKey"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
   File "/home/container/.local/lib/python3.11/site-packages/pydactyl/api_client.py", line 69, in __init__
     adapter = http_adapter(backoff_factor=backoff_factor,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/container/.local/lib/python3.11/site-packages/pydactyl/api_client.py", line 16, in http_adapter
     retries = requests.packages.urllib3.util.retry.Retry(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist'

Environment

Additional context I'm sure it's not my program, it worked perfectly before the new version Either it's the requests module or it's the py-dactyl module

Tarkhubal commented 1 year ago

Okay it's the request module I went back a version back and that's it

gamedev-mjota commented 1 year ago

Yes, I'm experiencing the same. What I did is I replaced method_whitelist with allowed_methods in

def http_adapter(backoff_factor, retries, extra_retry_codes):
    """Configures an HTTP adapter with retries and backoff."""
    retry_codes = [429] + extra_retry_codes
    retries = requests.packages.urllib3.util.retry.Retry(
        total=retries, status_forcelist=retry_codes,
        backoff_factor=backoff_factor,
        allowed_methods=['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'])
    adapter = requests.adapters.HTTPAdapter(max_retries=retries)
    return adapter

Created a pull request: https://github.com/iamkubi/pydactyl/pull/77

Tarkhubal commented 1 year ago

I found the same issues in the requests module's github

iamkubi commented 1 year ago

Fixed in the 2.0.2 release