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

Move Black into a plugin to enable turning it on and off via backend_plugins #8683

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions pants.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ pythonpath: [

backend_packages: +[
"pants.backend.docgen",
"internal_backend.rules_for_testing",
"internal_backend.repositories",
"internal_backend.sitegen",
"internal_backend.utilities",
"pants.contrib.avro",
"pants.contrib.awslambda.python",
"pants.contrib.buildrefactor",
Expand All @@ -66,6 +62,10 @@ backend_packages: +[
"pants.contrib.python.checks",
"pants.contrib.scrooge",
"pants.contrib.thrifty",
"internal_backend.rules_for_testing",
"internal_backend.repositories",
"internal_backend.sitegen",
"internal_backend.utilities",
Copy link
Contributor

Choose a reason for hiding this comment

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

Good change!

]

# The pants script in this repo consumes these files to run pants
Expand All @@ -82,8 +82,6 @@ pants_ignore: +[
'/build-support/bin/native/src',
]

[black]
config: pyproject.toml

[cache]
# Caching is on globally by default, but we disable it here for development purposes.
Expand Down
Empty file.
46 changes: 46 additions & 0 deletions src/python/pants/backend/python/lint/black/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
'3rdparty/python:dataclasses',
'src/python/pants/backend/python/subsystems',
'src/python/pants/backend/python/rules',
'src/python/pants/backend/python/targets',
'src/python/pants/engine:fs',
'src/python/pants/engine:isolated_process',
'src/python/pants/engine:rules',
'src/python/pants/engine:selectors',
'src/python/pants/option',
'src/python/pants/rules/core',
],
)

python_tests(
name='tests',
sources=globs('*_test.py', exclude=[globs('*_integration_test.py')]),
dependencies=[
':black',
],
)


python_tests(
name='integration',
sources=globs('*_integration_test.py'),
dependencies=[
':black',
'src/python/pants/backend/python/subsystems',
'src/python/pants/backend/python/targets',
'src/python/pants/engine:fs',
'src/python/pants/engine:rules',
'src/python/pants/engine:selectors',
'src/python/pants/engine/legacy:structs',
'src/python/pants/rules/core',
'src/python/pants/source',
'src/python/pants/testutil:test_base',
'src/python/pants/testutil/subsystem',
],
tags = {'integration'},
timeout = 90,
)
Empty file.
13 changes: 13 additions & 0 deletions src/python/pants/backend/python/lint/black/register.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).


from pants.backend.python.lint.black import rules as black_rules
from pants.backend.python.targets import formattable_python_target


def rules():
return (
*black_rules.rules(),
*formattable_python_target.rules(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from pathlib import Path
from typing import Optional, Tuple

from pants.backend.python.lint.black.subsystem import Black
from pants.backend.python.rules.pex import (
CreatePex,
Pex,
PexInterpreterConstraints,
PexRequirements,
)
from pants.backend.python.subsystems.black import Black
from pants.backend.python.subsystems.python_setup import PythonSetup
from pants.backend.python.subsystems.subprocess_environment import SubprocessEncodingEnvironment
from pants.backend.python.targets.formattable_python_target import FormattablePythonTarget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

from typing import List, Optional, Tuple

from pants.backend.python.rules.black import BlackSetup, fmt, lint, setup_black
from pants.backend.python.lint.black.rules import BlackSetup, fmt, lint, setup_black
from pants.backend.python.lint.black.subsystem import Black
from pants.backend.python.rules.download_pex_bin import download_pex_bin
from pants.backend.python.rules.pex import CreatePex, create_pex
from pants.backend.python.subsystems.black import Black
from pants.backend.python.subsystems.python_native_code import (
PythonNativeCode,
create_pex_native_build_environment,
Expand Down
4 changes: 0 additions & 4 deletions src/python/pants/backend/python/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
from pants.backend.python.python_requirement import PythonRequirement
from pants.backend.python.python_requirements import PythonRequirements
from pants.backend.python.rules import (
black,
download_pex_bin,
inject_init,
pex,
python_create_binary,
python_test_runner,
)
from pants.backend.python.subsystems import python_native_code, subprocess_environment
from pants.backend.python.targets import formattable_python_target
from pants.backend.python.targets.python_app import PythonApp
from pants.backend.python.targets.python_binary import PythonBinary
from pants.backend.python.targets.python_distribution import PythonDistribution
Expand Down Expand Up @@ -94,9 +92,7 @@ def register_goals():

def rules():
return (
*black.rules(),
*download_pex_bin.rules(),
*formattable_python_target.rules(),
*inject_init.rules(),
*pex.rules(),
*python_test_runner.rules(),
Expand Down
13 changes: 1 addition & 12 deletions src/python/pants/backend/python/rules/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,9 @@ python_tests(
name='integration',
sources=globs('*_integration_test.py'),
dependencies=[
':rules',
'src/python/pants/backend/python/subsystems',
'src/python/pants/backend/python/targets',
'src/python/pants/engine:fs',
'src/python/pants/engine:rules',
'src/python/pants/engine:selectors',
'src/python/pants/engine/legacy:structs',
'src/python/pants/rules/core',
'src/python/pants/source',
'src/python/pants/testutil:test_base',
'src/python/pants/testutil/subsystem',
'src/python/pants/testutil:int-test',
'testprojects/tests/python/pants:dummies_directory',
],
tags = {'integration'},
timeout = 160,
timeout = 90,
)