msherry / flycheck-pycheckers

Multiple syntax checker for Python in Emacs, using Flycheck
GNU General Public License v3.0
63 stars 23 forks source link

Python 3? #64

Open efroemling opened 2 years ago

efroemling commented 2 years ago

I was recently reading that the next minor update to macOS (12.3) will finally remove python 2.x (not to mention that 2.x has been EOL for a while now) which got me wondering if porting pycheckers to 3.x would be a big pain.

If someone wants to run a 2to3 pass and set up a test branch or something, I'd be happy to help test it out (at least the mypy3 and pylint checkers). Also happy to set up said branch myself otherwise. Anyone else interested or has anyone tried this already?

msherry commented 2 years ago

Hi there - thanks for the issue!

What changes would be involved in porting to py3? AFAIK it currently runs correctly, so would this just involve modernizing the code style in a non-backwards-compatible way (i.e., does this issue really mean dropping support for py2)?

efroemling commented 2 years ago

Oh; if it already runs correctly under 3, that's great news. Then maybe the only change needed would be to change the script's shebang to #!/usr/bin/env python3? (According to Pep-394 python isn't supposed to point at Python 3, though perhaps this is changing now that Python 2 is going away?..)

Perhaps the best option would be allowing specifying the python command to invoke for the script instead of relying on the shebang? (or is this already in there somewhere?)

efroemling commented 2 years ago

Actually, on reading over Pep-394 again, it sounds like allowing python to point to a python 3 version might be a more acceptable thing than I remembered. So perhaps nothing at all needs to be done if that is the case?...

Though perhaps configurability or some other smarts could still be useful since plain 'python' is becoming more rare. (and latest macOS currently pops up a scary 'This software needs to be updated' dialog anytime something invokes 'python')

szykes commented 1 year ago

Hi,

I experienced similar issue that is written in the previous comment.

I use macOS 12.6 and there is no called python just python3. Therefore, when the flychecker-pycheckers runs bin/pycheckers.py, it will result error env: python: No such file or directory.

Changing shebang to python3 solves the problem but this is not the right solution.

Would it be possible to make this change official?

msherry commented 1 year ago

@szikes-adam thank you for your comment! If I am understanding your request correctly, you are asking to make this change, correct?

diff --git a/bin/pycheckers.py b/bin/pycheckers.py
index d59bf20..69209c9 100755
--- a/bin/pycheckers.py
+++ b/bin/pycheckers.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """A hacked up version of the multiple-Python checkers script from EmacsWiki.

 Original work taken from http://www.emacswiki.org/emacs/PythonMode, author

This would have the effect of dropping python 2 compatibility. Do you know if it's common to only have python3 on a system, with no executable (symlink or otherwise) called just python?

szykes commented 1 year ago

This would have the effect of dropping python 2 compatibility. Do you know if it's common to only have python3 on a system, with no executable (symlink or otherwise) called just python?

Yes, I think. I have checked the vanilla Ubuntu 22.04 and it does not contain python binary, only python3. However, Ubuntu has own package the python-is-python3 that solves the issue. But we need to assume not everyone has sudo right on their Linux.

I have been thinking about this problem. Actually the true question is: whether your script will work properly, if the system runs pycheckers.py with python3 and the edited code is python2? I guess the answer is yes and in this case, you can commit your change because the first release of python 3 was in end of 2008.

bernarduh commented 1 year ago

Hi there.

I'm having trouble running bin/pycheckers.py on a fresh install of Ubuntu 22.04.

The issues I have are:

All issues come down to having this script properly migrated to Python3.

I understand that developers might have to continue supporting Python2 scripts and therefore it could be useful that this script is to be able to lint Python2 scripts. But that doesn't mean running our development environment on a system that still uses Python2. I think it is time for us to migrate this script to Python3 eventought we can try to keep support linting Python2 scripts.

bernarduh commented 1 year ago

I made some changes regarding the above in a branch. How can I submit the changes for review? Should I fork the repo for this?

msherry commented 1 year ago

I think a fork and PR would be great!