kaste / PyTest

pytest runner and view annotator for sublime text
21 stars 6 forks source link

Sublimetext 4 Support #28

Closed YoSTEALTH closed 3 years ago

YoSTEALTH commented 3 years ago

Would like to see this package working for sublime text 4

kaste commented 3 years ago

Hm, I don't have ST4 yet. I thought ST4 is backwards compatible; what's the issue here?

YoSTEALTH commented 3 years ago

I can run Pytest and get build output but none of the color highlighting and such works.

kaste commented 3 years ago

No exceptions thrown in the console. 😢

YoSTEALTH commented 3 years ago

None I can see. It might not be an error thing more of a missing feature or accounting for api change? I dono.

jodylent commented 3 years ago

Diagnosed and possibly fixed here: https://github.com/kaste/PyTest/pull/29

YoSTEALTH commented 3 years ago

wait, trying to test

YoSTEALTH commented 3 years ago

When I update the code with https://raw.githubusercontent.com/kaste/PyTest/533ceafb78f165501de46ae3098cada579669f1a/pytest_exec.py

YoSTEALTH commented 3 years ago

While I was reinstalling PyTest

Traceback (most recent call last):
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 308, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
zipimport.ZipImportError: bad local file header in /.../.config/sublime-text/Installed Packages/PyTest.sublime-package
kaste commented 3 years ago

As of now, https://packagecontrol.io/packages/PyTest has not yet seen the new version. Generally, when you see a ZipImportError you downloaded a corrupt file, or hit a race where Package Control tried to extract the file before the download was finished/the file closed iirc. Anyhow, a restart should fix this automatically.

Just grabbing one file from a PR is error-prone. It is actually very easy to test Sublime packages, you just git clone the package in to the Packages folder and then checkout a branch etc. A restart is usually necessary as this simple package here does not ship any hot-reloading. SublimeLinter and GitSavvy for example ship hot-reloading code so that switching branches etc. does not require a restart.

kaste commented 3 years ago

(Yeah, I have flake8 errors in the file. Back then, flake8 did not read type annotations and I just added them for my reading as I did not know how to actually run a type checker, for example mypy, on a Sublime Text plugin.) 🤷

Now nobody wants to fix this mess.

YoSTEALTH commented 3 years ago

Ok, got it directly from here, seems to have worked, I can see the GREEN color one success.

I am not really a big fan of using Type-hinting with the code itself, makes it really hard to read the code. I normally just add type info into doc string:

'''
Type
    var:    int
    return: None
'''

You can see any of my projects to see how I actually use it.

As for mypy, you can just run mypy myfile.py and it should check types. But your sublime users aren't going to be using mypy so type can't be restricted.

Thanks @kaste also @jodylent for debugging the issue :+1: