Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature More support for Python 3 and mixed Python 2, 2+3 and 3 #25

Closed
wants to merge 2 commits into from
Closed

Feature More support for Python 3 and mixed Python 2, 2+3 and 3 #25

wants to merge 2 commits into from

Conversation

bennygomspace
Copy link

Stuff relevant primary during migration to Python 3 added

  • Added checkers:
    ** pylint-py3k (Command: pylint --py3k)
    ** pylint3

  • Autodection if a file shall be checked with a subset of the specifed checkers:
    ** Python 2 compatible checkers
    ** Python 3 compatible checkers
    ** Both Python 2 and 3 compatible checkers
    There will never be checked with checkers not specified via arg --checkers or in CHECKERS=... in config file.

Autodection is only active if enabled via arg --py23-autodetect or PY23_AUTODETECT = 1 in config file

I think it is relevant to also check with pylint3 while preparing and
during migration from Python 2 to 2+3 or 3.

pylint --py3k might also show some things to fix, so that have also
been added.

Option pylint_rcfile is common for all pylint* commands, just as for mypy*.

Note: README.md is updated manually, since generating it using
el2markdown, generates a lot of changes.
The autodect is performed via checking python version in #!/... line
or a # py:<version, e.g. '2', '23', '3'> line.

See README.md for details.
Copy link
Owner

@msherry msherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice, thank you! A couple of suggested changes, but overall I like the direction this is going.

@@ -535,6 +537,30 @@ def process_returncode(self, returncode):
return not (returncode & 1 or returncode & 32)


class PylintPy3kRunner(PylintRunner):
"""Run pylint --py3k, producing flymake readable output.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's copied from existing checkers (that I need to fix!), but can we change "flymake" to "flycheck"?



class Pylint3Runner(PylintRunner):
"""Run pylint3, producing flymake readable output.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, s/flymake/flycheck/.

'''
Check if first line says python/python2/python3 => Activate py2/3 checkers

Can be overruled via a line: # py:<version>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Is this a common convention, or just something you decided?

Check if first line says python/python2/python3 => Activate py2/3 checkers

Can be overruled via a line: # py:<version>
If <version> contains 2 -> then set py2 (1th return value)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "1st" instead of "1th".

@@ -753,11 +787,63 @@ def update_options_locally(options):
return options


def py2_py3_enable(py23_autodetect, source_file_path):
# type: (str) -> bool, bool
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type signature looks wrong -- there are two parameters, but only one input type.

@msherry msherry force-pushed the master branch 2 times, most recently from e64d6cd to e588b5f Compare December 28, 2018 02:32
@sorennohr
Copy link

#####################################
Subject: Review of flycheck-pycheckers pull #25
Hi Marc

#25

Unfortunate Benny can't make the changes.
If you can make the changes, it will be great!

It's fine with us to:

  • s/flymake/flycheck/g (twice)
  • s/1th/1st/
  • Auto-detection: See below
  • Add 1st input bool:

    type: (bool, str) -> bool, bool

Auto-detection
1st line
The auto detection if the first line is a simple matching for both
#!/path/to/pythonX and #!/usr/bin/env pythonX - any other pythonX
where X can be empty, 2 or 3.
The check is made simple, so bad #! formatted lines are recognized.

py:

The # py: was not found elsewhere, actually we have not found any checking-help for python2-> 2+3 or 3 migration. (2to3 and futurize can modify the code but not show mistakes (well)).

The background was:
Space after # to let checkers be happy (some rules claims if space after # is missing)
py: Just a short identifier
could be stricter checking, but a simple search for 2 and 3

@GomSpace GomSpace closed this by deleting the head repository Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants