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

Pants lint engine only supports Python 2 #5764

Closed
CMLivingston opened this Issue Apr 27, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@CMLivingston
Contributor

CMLivingston commented Apr 27, 2018

The pants lint engine in the contrib directory only supports Python 2 linting at the moment, even if lint plugins are capable of supporting static analysis on Python 3 ASTs. This is due to the lint engine using the Python 2 stdlib ast module to parse the source code for plugin consumption. Since ast cannot parse code that is not compatible with the interpreter that invokes ast.parse, this inherently blocks other Python versions from being able to parse and lint properly.

The scope of this ticket is to investigate Python code that is incompatible with the interpreter running Pants.

wisechengyi added a commit that referenced this issue Apr 30, 2018

Disable lint for Python 3 targets (#5765)
### Problem

`./pants lint` fails on targets containing source code that utilizes Python 2-incompatible syntax.

### Solution

Disable lint when targeting Python 3. Track long-term solution with #5764.

### Result

Python 3 targets utilizing Python 3-specific syntax will be able to pass lint.

wisechengyi added a commit that referenced this issue May 1, 2018

Disable lint for Python 3 targets (#5765)
### Problem

`./pants lint` fails on targets containing source code that utilizes Python 2-incompatible syntax.

### Solution

Disable lint when targeting Python 3. Track long-term solution with #5764.

### Result

Python 3 targets utilizing Python 3-specific syntax will be able to pass lint.

@jsirois jsirois self-assigned this Oct 9, 2018

@jsirois jsirois added the in-progress label Oct 9, 2018

jsirois added a commit to jsirois/pants that referenced this issue Oct 11, 2018

Run pythonstyle under the appropriate interpreter.
This breaks the pythonstyle lint task up into a task frontend and pex
backend. This splitting allows the backend to be run under any
interpreter Pants supports and thus support linting python 3 code for
example.

Fixes pantsbuild#5764

jsirois added a commit to jsirois/pants that referenced this issue Oct 11, 2018

Run pythonstyle under the appropriate interpreter.
This breaks the pythonstyle lint task up into a task frontend and pex
backend. This splitting allows the backend to be run under any
interpreter Pants supports and thus support linting python 3 code for
example.

Fixes pantsbuild#5764

jsirois added a commit that referenced this issue Oct 12, 2018

Run pythonstyle under the appropriate interpreter. (#6618)
This breaks the pythonstyle lint task up into a task frontend and pex
backend. This splitting allows the backend to be run under any
interpreter Pants supports and thus support linting python 3 code for
example.

Fixes #5764

@jsirois jsirois removed the in-progress label Oct 12, 2018

@StephanErb

This comment has been minimized.

Contributor

StephanErb commented Oct 14, 2018

@jsirois this ticket is now resolved but linting is still disabled and references this ticket here. Am I missing something?

https://github.com/pantsbuild/pants/blob/master/contrib/python/src/python/pants/contrib/python/checks/tasks/checkstyle/checkstyle.py#L173

@jsirois

This comment has been minimized.

Member

jsirois commented Oct 15, 2018

@StephanErb I was interpreting the ticket a bit narrowly. The lint engine now supports python3, but agreed that it makes sense to re-open until the lint task supports python3.

@jsirois

This comment has been minimized.

Member

jsirois commented Oct 15, 2018

@CMLivingston I've re-opened and added you as an assignee so you can close once #6606 is merged.

@jsirois jsirois added in-progress and removed in-progress labels Oct 16, 2018

stuhood added a commit that referenced this issue Oct 18, 2018

Fix python lint dependency on pyprep goal (#6606)
### Problem

Python linting for a target set that contains incompatible python version constraints throws a fatal exception and terminates the lint run. This happens because the lint task is coupled to pyprep, triggering interpreter selection for the target closure.

### Solution

Use InterpreterCache to partition the target set based on compatibility constraint, and run the link task for each partition.

### Result

Linting incompatible target closures does not throw an exception and instead lints each constraint partition of the closure separately.

Resolves: #5764

stuhood added a commit that referenced this issue Oct 18, 2018

Fix python lint dependency on pyprep goal (#6606)
### Problem

Python linting for a target set that contains incompatible python version constraints throws a fatal exception and terminates the lint run. This happens because the lint task is coupled to pyprep, triggering interpreter selection for the target closure.

### Solution

Use InterpreterCache to partition the target set based on compatibility constraint, and run the link task for each partition.

### Result

Linting incompatible target closures does not throw an exception and instead lints each constraint partition of the closure separately.

Resolves: #5764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment