mtshiba / pylyzer

A fast static code analyzer & language server for Python
http://mtshiba.github.io/pylyzer/
MIT License
2.15k stars 34 forks source link

"time" object has no attribute sleep #95

Closed lion24 closed 6 days ago

lion24 commented 1 week ago

Hi there 👋

I probably getting something wrong, but I cannot spot the issue.

I did install using:

pip install pylyzer

Version:

PS > pylyzer --version
pylyzer 0.0.54

And I tried to against a simple file import a module from the standard library:

import time

def test_sleep():
    time.sleep(1)
    print("Slept for 1 second")

if __name__ == "__main__":
    test_sleep()

Running pylyzer lead to a "object has no attribute sleep" error:

pylyzer .\sleep.py
Start checking: sleep.py
Found 1 errors: sleep.py
Error[#1393]: File .\sleep.py, line 5, <module>.test_sleep

5 |     time.sleep(1)
  :          -----

AttributeError: PyModule("c:\\users\\lion24\\.erg\\lib\\pystd\\time.d.er") object has no attribute sleep

In the meantime time.d.er looks good:

PS > type c:\users\lion24\.erg\lib\pystd\time.d.er\time.d.er
.sleep!: Float => NoneType
.time!: () => Float

.StructTime = 'struct_time': ClassType
.StructTime.
    tm_year: Nat
    tm_mon: Nat
    tm_mday: Nat
    tm_hour: Nat
    tm_min: Nat
    tm_sec: Nat
    tm_wday: Nat
    tm_yday: Nat
    tm_isdst: Nat
    tm_zone: Str
    tm_gmtoff: Nat

And I'm running on Windows 10.

lion24 commented 1 week ago

I checked on Linux and it works fine. So I guess this is an error related to windows.

mtshiba commented 1 week ago

The part that seemed to be the problem has been fixed in https://github.com/mtshiba/pylyzer/commit/974269a2ba48d4afcd4a65e3fd55209680ae585d.

Please uninstall pylyzer and reinstall it.

lion24 commented 6 days ago

The part that seemed to be the problem has been fixed in 974269a.

Please uninstall pylyzer and reinstall it.

Yup it works !

A small quirk, I manually had to remove the .erg folder from the user directory, I guess because when doing uninstallation, files are left intact.

But now it works fine :)