websockify icon indicating copy to clipboard operation
websockify copied to clipboard

Add lint workflow

Open notypecheck opened this issue 11 months ago • 9 comments

Closes #600

This PR adds:

Package Manager

https://docs.astral.sh/uv/ Tool to manage project dependencies, with support for pyproject.toml (https://peps.python.org/pep-0621/)

Mypy

https://github.com/python/mypy Static type checker

Ruff

https://docs.astral.sh/ruff/ Linter and formatter

workflows/lint.yaml uses python 3.12, I don't think this should be an issue as long as target versions are configured properly for ruff and mypy.

notypecheck avatar Mar 12 '25 18:03 notypecheck

Latest versions of mypy and ruff only support python 3.8 and 3.7 respectively 🤔

notypecheck avatar Mar 12 '25 18:03 notypecheck

Latest versions of mypy and ruff only support python 3.8 and 3.7 respectively 🤔

Comparing to novnc compatibility you mean ?

What versions of Python does Ruff support? Ruff can lint code for any Python version from 3.7 onwards, including Python 3.13. [...] Ruff is installable under any Python version from 3.7 onwards.

And for mypy it seems to be : Requires: Python >=3.9 https://pypi.org/project/mypy/

d0tiKs avatar Mar 12 '25 21:03 d0tiKs

Comparing to novnc compatibility you mean ?

Yes, currently latest release of websockify on pypi states it's compatible with 3.4 and on master branch it's 3.6. As for mypy - it's possible to use slightly older version, I think that's already handled in uv.lock:

[package.dev-dependencies]
dev = [
    { name = "mypy", version = "0.971", ..., marker = "python_full_version < '3.7'" },
    { name = "mypy", version = "1.4.1", ..., marker = "python_full_version == '3.7.*'" },
    { name = "mypy", version = "1.14.1", ..., marker = "python_full_version == '3.8.*'" },
    { name = "mypy", version = "1.15.0", ..., marker = "python_full_version >= '3.9'" },
]

only quite early version of ruff (0.0.17) supports 3.6 though

notypecheck avatar Mar 13 '25 00:03 notypecheck

Also it seems like only ~3% of downloads are for python 3.6 and 3.7 https://pypistats.org/packages/websockify

notypecheck avatar Mar 13 '25 00:03 notypecheck

@ThinLinc-Zeijlon Sorry to ping you, but I'm not quite sure who maintains the repository right now, but I see that the last commit/release was made by you.
Would you have a bit of time to glance over this PR? Last commit (the one that runs ruff format) can probably be rolled back to reduce review time, and one of the maintainers could run it locally.

notypecheck avatar Mar 16 '25 19:03 notypecheck

@ThirVondukr, Thank you for your patience, I'll take a look at your changes :slightly_smiling_face:

CendioZeijlon avatar Apr 14 '25 12:04 CendioZeijlon

@CendioOssman and @samhed, what are your thoughts on adding ruff as a linter for us?

CendioZeijlon avatar Jun 04 '25 11:06 CendioZeijlon

I'd prefer something more traditional, like flake8. It'll be more generally available and familiar to people.

CendioOssman avatar Jun 05 '25 07:06 CendioOssman

@CendioOssman ruff should include majority of rules from flake8 and it's plugins, you can toggle the rules that you think would be useful: https://docs.astral.sh/ruff/rules/

notypecheck avatar Jun 10 '25 11:06 notypecheck