Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

argument 'milliseconds' has unexpected type 'float' #119

Open
benthetechguy opened this issue Jan 11, 2022 · 10 comments · May be fixed by #120
Open

argument 'milliseconds' has unexpected type 'float' #119

benthetechguy opened this issue Jan 11, 2022 · 10 comments · May be fixed by #120

Comments

@benthetechguy
Copy link

I'm on Arch. The daemon works fine but if I try to run nuxhash-gui I get this error:

Traceback (most recent call last):
  File "/usr/bin/nuxhash-gui", line 33, in <module>
    sys.exit(load_entry_point('nuxhash==1.0.0b2', 'console_scripts', 'nuxhash-gui')())
  File "/usr/lib/python3.10/site-packages/nuxhash/__init__.py", line 7, in nuxhash_gui
    main()
  File "/usr/lib/python3.10/site-packages/nuxhash/gui/main.py", line 146, in main
    frame = MainWindow(None, title='nuxhash')
  File "/usr/lib/python3.10/site-packages/nuxhash/gui/main.py", line 42, in __init__
    MiningScreen(notebook, devices=self._Devices),
  File "/usr/lib/python3.10/site-packages/nuxhash/gui/mining.py", line 57, in __init__
    self._Timer.Start(milliseconds=BALANCE_UPDATE_MIN*60*1e3)
TypeError: Timer.Start(): argument 'milliseconds' has unexpected type 'float'

After the error, the program quits. It then starts again, shows the error, then quits, and repeat. This makes it hard to kill the program since the PID is always going up, so I had to resort to a reboot to stop this. It seems like others are also having this error.

@benthetechguy
Copy link
Author

I've discovered that the GUI works if I use a Python 3.9 venv, so it looks like it's an issue with the code not working in Python 3.10.

@cprn
Copy link

cprn commented Jan 11, 2022

nuxhash/gui/mining.py:

self._Timer.Start(milliseconds=BALANCE_UPDATE_MIN*60*1e3)

Shouldn't it be multiplied by 1000 instead of 1e3? Numbers with exponents are floats and milliseconds is expected to be int.

@benthetechguy
Copy link
Author

I'll check if changing that fixes it. I would be annoyed because I just released an entire new AUR package based around keeping it at 3.9, and this fix would revoke that package's need for existence, plus I would need to bump the main one's pkgrel again, but I digress. It's always good to find fixes.

@benthetechguy
Copy link
Author

benthetechguy commented Jan 11, 2022

I just patched out a whole bunch of floats that should be ints. This guy sure is into ending numbers with .0 for whatever reason. Now I'm getting a new error:

Traceback (most recent call last):
  File "/usr/bin/nuxhash-gui", line 33, in <module>
    sys.exit(load_entry_point('nuxhash==1.0.0b2', 'console_scripts', 'nuxhash-gui')())
  File "/usr/lib/python3.10/site-packages/nuxhash/__init__.py", line 7, in nuxhash_gui
    main()
  File "/usr/lib/python3.10/site-packages/nuxhash/gui/main.py", line 146, in main
    frame = MainWindow(None, title='nuxhash')
  File "/usr/lib/python3.10/site-packages/nuxhash/gui/main.py", line 66, in __init__
    pub.sendMessage('data.settings', settings=loaded_settings)
  File "/usr/lib/python3.10/site-packages/pubsub/core/publisher.py", line 216, in sendMessage
    topicObj.publish(**msgData)
  File "/usr/lib/python3.10/site-packages/pubsub/core/topicobj.py", line 452, in publish
    self.__sendMessage(msgData, topicObj, msgDataSubset)
  File "/usr/lib/python3.10/site-packages/pubsub/core/topicobj.py", line 482, in __sendMessage
    listener(data, self, allData)
  File "/usr/lib/python3.10/site-packages/pubsub/core/listener.py", line 237, in __call__
    cb(**kwargs)
  File "/usr/lib/python3.10/site-packages/nuxhash/gui/settings.py", line 158, in _OnSettings
    self._Reset()
  File "/usr/lib/python3.10/site-packages/nuxhash/gui/settings.py", line 195, in _Reset
    self._Threshold.SetValue(self._Settings['switching']['threshold']*100)
TypeError: SpinCtrl.SetValue(): arguments did not match any overloaded call:
  overload 1: argument 1 has unexpected type 'float'
  overload 2: argument 1 has unexpected type 'float'

@cprn
Copy link

cprn commented Jan 11, 2022

Honestly there might be quite a lot of these. I'm not an avid python coder but AFAIU there was a significant change in how type hints are treated, i.e. they were more or less ignored in 3.9 and only used by static analyzers, now 3.10 throws a TypeError exception by default. My understanding, up until now, was that it can be somehow disabled but I can't seem to find how. It's a sensitive subject - what constitutes a TypeError and what doesn't changes frequently between minor versions. 🤷‍♂️

@benthetechguy
Copy link
Author

benthetechguy commented Jan 11, 2022

I'd really like to find that method to ignore them, this is getting to be a nightmare with patching so much that it's almost a new program, and some things that I'm not smart enough to patch (new to python).

@cprn
Copy link

cprn commented Jan 11, 2022

Sadly the only two ways I found (mentioned in PEP 484 and 526) are:

  • # type: ignore comment in the same line as the type hint
  • @no_type_check decorator for method containing type hints

Neither is convenient. Sorry I can't be of more help. I remember someone telling me there is a way to make Python ignore those in whole source or at least per file but IDK how or where to find it.

@benthetechguy
Copy link
Author

No worries, thank you for your help. I guess my hacky 3.9 venv method will have to do until I, you, or someone else finds more info about this.

@cprn
Copy link

cprn commented Jan 11, 2022

TypeError: SpinCtrl.SetValue(): arguments did not match any overloaded call:
overload 1: argument 1 has unexpected type 'float'
overload 2: argument 1 has unexpected type 'float'

According to wx.SpinCtrl.SetValue() documentation it accepts 1 argument of 2 possible types:

  • text (which I'm guessing isn't what we want here)
  • int

For this argument to be int the value of self._Settings['switching']['threshold'] multiplied by 100 has to be int as well. It's read from ~/.config/nuxhash/settings.conf and set to 0.1 by default so the result is 10.0. I'd add casting in line 195 of settings.py, like so:

self._Threshold.SetValue(int(self._Settings['switching']['threshold']*100))

(sorry I don't just do it myself but I'm on a phone on a week long mountain trip)

@benthetechguy
Copy link
Author

Thank you, that was the final patch I needed! Pushing the changes to the AUR, and making a PR on this repo, though it's unlikely to get accepted. Actually, about that, I saw an interesting message by @YoRyan himself in one of the more popular forks talking about potentially transferring control of this repo or making that fork official. I hope you have a good time on your mountain trip!

@benthetechguy benthetechguy linked a pull request Jan 11, 2022 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants