Skip to content

Commit

Permalink
Internally enable Flake8 lints for invalid whitespace (#9866)
Browse files Browse the repository at this point in the history
W291 - Trailing whitespace
W293 - blank line contains whitespace
  • Loading branch information
asherf committed May 26, 2020
1 parent 8d95788 commit 36f7646
Show file tree
Hide file tree
Showing 35 changed files with 132 additions and 134 deletions.
2 changes: 0 additions & 2 deletions build-support/flake8/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ extend-ignore:
E501, # line too long (> 79 characters)
E731, # Do not assign a lambda expression
E741, # Ambiguous variable name (enable once fixed)
W291, # Trailing whitespace (enable once fixed)
W293, # Blank line contains whitespace (enable once fixed)
W503, # line break before binary operator (conflicts with Black)
W605, # invalid escape sequence (enable once fixed)
PB10, # Bad class attribute (enable once fixed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_noop_applicable_targets_complete_graph(self):
contents=dedent(
"""
package jane
var PublicConstant = 42
"""
),
Expand Down Expand Up @@ -172,12 +172,12 @@ def stitch_deps_local(self, materialize):
contents=dedent(
"""
package main
import (
"fmt"
"jane"
)
func main() {
fmt.Printf("Hello %s!", jane.PublicConstant)
}
Expand Down Expand Up @@ -235,9 +235,9 @@ def stitch_deps_remote(self, remote=True, materialize=False, fail_floating=False
contents=dedent(
"""
package jane
import "pantsbuild.org/fake/prod"
var PublicConstant = prod.DoesNotExistButWeShouldNotCareWhenCheckingDepsAndNotInstalling
"""
),
Expand All @@ -247,12 +247,12 @@ def stitch_deps_remote(self, remote=True, materialize=False, fail_floating=False
contents=dedent(
"""
package main
import (
"fmt"
"jane"
)
func main() {
fmt.Printf("Hello %s!", jane.PublicConstant)
}
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_issues_2616(self):
contents=dedent(
"""
package jane
var PublicConstant = 42
"""
),
Expand All @@ -352,17 +352,17 @@ def test_issues_2616(self):
contents=dedent(
"""
package main
/*
#include <stdlib.h>
*/
import "C" // C was erroneously categorized as a remote lib in issue 2616.
import (
"fmt"
"jane"
)
func main() {
fmt.Printf("Hello %s!", jane.PublicConstant)
fmt.Printf("Random from C: %d", int(C.random()))
Expand Down Expand Up @@ -392,7 +392,7 @@ def test_issues_2787(self):
contents=dedent(
"""
package helper
const PublicConstant = 42
"""
),
Expand All @@ -403,7 +403,7 @@ def test_issues_2787(self):
contents=dedent(
"""
package lib
const privateConstant = 42
"""
),
Expand All @@ -414,12 +414,12 @@ def test_issues_2787(self):
contents=dedent(
"""
package lib_test
import (
"helper"
"testing"
)
func TestAdd(t *testing.T) {
if privateConstant != helper.PublicConstant {
t.Fatalf("got: %d, expected: %d", privateConstant, helper.PublicConstant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ def test_issues_2616(self):
"src/github.com/u/a/a.go",
contents="""
package a
import (
"fmt"
"math"
"sync"
"bitbucket.org/u/b"
)
""",
Expand All @@ -204,15 +204,15 @@ def test_issues_2616(self):
"src/github.com/u/a/b.go",
contents="""
package a
/*
#include <stdlib.h>
*/
import "C" // C was erroneously categorized as a remote lib in issue 2616.
import (
"fmt"
"github.com/u/c"
)
""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def test_go_test_unstyle(self):
dedent(
"""
package libUnstyle
func Speak() {
println("Hello from libUnstyle!")
println("Bye from libUnstyle!")
}
func Add(a int, b int) int {
return a + b
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def _create_thrift_project(self, thrift_files):
dedent(
"""
package usethrift
import "thrifttest/duck"
func whatevs(f duck.Feeder) string {
d := duck.NewDuck()
f.Feed(d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def _get_mypy_pex(self, py3_interpreter: PythonInterpreter, *extra_pexes: PEX) -
os.path.realpath(p)
for p in os.environ.get('PYTHONPATH', '').split(os.pathsep)
)
site.getsitepackages = lambda: [
p for p in sys.path if os.path.realpath(p) not in PYTHONPATH
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def _create_graph(self, broken_c_library=True):
"a.py": dedent(
"""
import inspect
def compile_time_check_decorator(cls):
if not inspect.isclass(cls):
raise TypeError('This decorator can only be applied to classes, given {}'.format(cls))
Expand All @@ -47,8 +47,8 @@ def compile_time_check_decorator(cls):
"b.py": dedent(
"""
from a.a import compile_time_check_decorator
@compile_time_check_decorator
class BarB(object):
pass
Expand All @@ -64,8 +64,8 @@ class BarB(object):
"c.py": dedent(
"""
from a.a import compile_time_check_decorator
@compile_time_check_decorator
{}:
pass
Expand All @@ -84,8 +84,8 @@ class BarB(object):
"d.py": dedent(
"""
from a.a import compile_time_check_decorator
@compile_time_check_decorator
class BazD(object):
pass
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/pants_info/list_backends_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_list_backends() -> None:
# V1 entry-point
def register_goals():
pass
# This naively looks like a V2 entry-point, but it's not!
def rules(x: int):
pass
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/pants_info/list_target_types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class CustomField(BoolField):
-------------
Tests for Fortran code.
This assumes that you use the FRUIT test framework.
Valid fields:
Expand All @@ -146,7 +146,7 @@ class CustomField(BoolField):
fortran_version
type: str | None, default: None
timeout
type: int | None, default: None
The number of seconds to run before timing out.
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/interpreter_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def select_interpreter_for_targets(self, targets):
dedent(
"""\
Unable to detect a suitable interpreter for compatibilities: {} (Conflicting targets: {})
Pants detected these interpreter versions on your system: {}
Possible ways to fix this:
* Modify your Python interpreter constraints by following https://www.pantsbuild.org/python_readme.html#configure-the-python-version.
* Ensure the targeted Python version is installed and discoverable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_includes_direct_dependencies(self) -> None:
name='transitive_req',
requirements=[python_requirement('django')],
)
python_requirement_library(
name='direct_req',
requirements=[python_requirement('ansicolors')],
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_includes_direct_dependencies(self) -> None:
'''Pylint will check that variables exist and are used.'''
from colors import green
from direct_dep import THIS_VARIABLE_EXISTS
print(green(THIS_VARIABLE_EXISTS))
"""
)
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_source_plugin(self) -> None:
name='pylint',
requirements=[python_requirement('pylint>=2.4.4,<2.5')],
)
python_requirement_library(
name='colors',
requirements=[python_requirement('ansicolors')],
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/tasks/pytest_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class InvalidShardSpecification(TaskError):
[run]
branch = True
timid = False
[report]
exclude_lines =
def __repr__
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/bin/pants_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def ensure_locale(cls):
"""
Your system's preferred encoding is `{}`, but Pants requires `UTF-8`.
Specifically, Python's `locale.getpreferredencoding()` must resolve to `UTF-8`.
Fix it by setting the LC_* and LANG environment settings. Example:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
Or, bypass it by setting the below environment variable.
Or, bypass it by setting the below environment variable.
{}=1
Note: we cannot guarantee consistent behavior with this bypass enabled.
""".format(
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/core/goals/fmt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def assert_expected(*, per_target_caching: bool) -> None:
f"""\
𐄂 FortranFormatter made changes.
{FortranTargets.stdout([fortran_address])}
𐄂 SmalltalkFormatter made changes.
{SmalltalkTargets.stdout([smalltalk_address])}
"""
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/engine/internals/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ def a_from_c_and_d(c: C, d: D) -> A:
File LOCATION-INFO, in fn_raises
raise Exception('An exception for {{}}'.format(type(x).__name__))
Exception: An exception for B
Computing Select(<{__name__}..B object at 0xEEEEEEEEE>, A)
Computing Task(a_from_c_and_d(), <{__name__}..B object at 0xEEEEEEEEE>, A, true)
Computing Task(c_from_b_nested_raise(), <{__name__}..B object at 0xEEEEEEEEE>, =C, true)
Expand Down

0 comments on commit 36f7646

Please sign in to comment.