Snuggle / hypixel.py

🎮 This is a simple, unofficial library for getting values from the public Hypixel-API in Python.
https://pypi.org/project/hypixel
MIT License
32 stars 6 forks source link

Error when setting keys #30

Closed ConnorTippets closed 3 years ago

ConnorTippets commented 3 years ago

I try to set the keys, and i get an UnboundLocalError, i believe this is because it sets response in the loop, but you're checking it outside the loop.

Traceback:

  File "[PYTHON PATH]\Python39\lib\site-packages\hypixel.py", line 127, in setKeys
    response = getJSON('key', key=api_key)
  File "[PYTHON PATH]\Python39\lib\site-packages\hypixel.py", line 66, in getJSON
    if response['success'] is False:
UnboundLocalError: local variable 'response' referenced before assignment
moresdv commented 3 years ago

@ConnorTippets

It would be more helpful to show the whole code but this should hopefully help you to find the right solution.

It says that you referenced a variable 'response' before assigning a value to it. There is written that you are trying to get something from the variable at line 66, but the variable doesen't exist yet.

It is better to read the error before opening a issue. Hoping that this helps, Mores92.

beardotpy commented 3 years ago

@ConnorTippets I'm pretty sure this is just a copy of https://github.com/Snuggle/hypixel.py/issues/20#issue-555352190

But yeah, I was going to use this API wrapper but I had to myerfire's API wrapper instead.

ConnorTippets commented 3 years ago

@ConnorTippets

It would be more helpful to show the whole code but this should hopefully help you to find the right solution.

It says that you referenced a variable 'response' before assigning a value to it. There is written that you are trying to get something from the variable at line 66, but the variable doesen't exist yet.

It is better to read the error before opening a issue. Hoping that this helps, Mores92.

I know what the error is, i know where it came from, what i'm confused about is how to fix it

Snuggle commented 3 years ago

Hello, @ConnorTippets! This hopefully is fixed by https://github.com/Snuggle/hypixel.py/commit/6903c76436f1ea66eb078356e2bf010af22d8b38. Could you please see if v0.8.0 of hypixel.py fixes this issue for you? If you use Python's PIP, you can run something like: pip install hypixel --upgrade to upgrade the package.