Skip to content

Commit

Permalink
Switch to using the new PythonEval task instead of the old one. (pant…
Browse files Browse the repository at this point in the history
…sbuild#4374)

The old one was broken anyway, so there's not much
to lose here...

This doesn't affect the Python backend tasks, so it's a good way to
dip a toe in the new pipeline waters.
  • Loading branch information
benjyw authored Mar 24, 2017
1 parent 72d7f0e commit b486753
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

from pants.goal.task_registrar import TaskRegistrar as task

from pants.contrib.python.checks.tasks2.python_eval import PythonEval as PythonEval2
from pants.contrib.python.checks.tasks2.python_eval import PythonEval
from pants.contrib.python.checks.tasks.checkstyle.checker import PythonCheckStyleTask
from pants.contrib.python.checks.tasks.python_eval import PythonEval


def register_goals():
task(name='python-eval', action=PythonEval).install('compile')
task(name='python-eval', action=PythonEval2).install('compile2')
task(name='pythonstyle', action=PythonCheckStyleTask).install('compile')
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ python_library(
'3rdparty/python:pep8',
'3rdparty/python:pyflakes',
'src/python/pants/backend/python/targets:python',
'src/python/pants/backend/python/tasks:python',
'src/python/pants/base:exceptions',
'src/python/pants/option',
'src/python/pants/subsystem',
'src/python/pants/task',
'src/python/pants/util:meta',
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
from collections import namedtuple

from pants.backend.python.targets.python_target import PythonTarget
from pants.backend.python.tasks.python_task import PythonTask
from pants.base.build_environment import get_buildroot
from pants.base.exceptions import TaskError
from pants.option.custom_types import file_option

from pants.contrib.python.checks.tasks.checkstyle.common import CheckSyntaxError, Nit, PythonFile
from pants.contrib.python.checks.tasks.checkstyle.file_excluder import FileExcluder
from pants.contrib.python.checks.tasks.checkstyle.register_plugins import register_plugins

from pants.option.custom_types import file_option
from pants.task.task import Task

_NOQA_LINE_SEARCH = re.compile(r'# noqa\b').search
_NOQA_FILE_SEARCH = re.compile(r'# (flake8|checkstyle): noqa$').search
Expand All @@ -39,7 +37,7 @@ def noqa_file_filter(python_file):
return any(_NOQA_FILE_SEARCH(line) is not None for line in python_file.lines)


class PythonCheckStyleTask(PythonTask):
class PythonCheckStyleTask(Task):
_PYTHON_SOURCE_EXTENSION = '.py'
_plugins = []
_subsystems = tuple()
Expand All @@ -52,7 +50,7 @@ def __init__(self, *args, **kwargs):

@classmethod
def subsystem_dependencies(cls):
return super(PythonTask, cls).subsystem_dependencies() + cls._subsystems
return super(Task, cls).subsystem_dependencies() + cls._subsystems

@classmethod
def register_options(cls, register):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from pants.backend.python.subsystems.python_setup import PythonSetup
from pants.backend.python.targets.python_binary import PythonBinary
from pants.backend.python.targets.python_library import PythonLibrary
from pants.backend.python.targets.python_target import PythonTarget
from pants.backend.python.tasks2.pex_build_util import (dump_requirements, dump_sources,
has_python_requirements, has_python_sources)
from pants.backend.python.tasks2.python_execution_task_base import WrappedPEX
from pants.backend.python.tasks2.resolve_requirements_task_base import ResolveRequirementsTaskBase
from pants.backend.python.tasks.python_task import PythonTask
from pants.base.exceptions import TaskError
from pants.base.generator import Generator, TemplateData
from pants.base.workunit import WorkUnit, WorkUnitLabel
Expand Down Expand Up @@ -217,7 +217,7 @@ def _get_executable_file_content(self, exec_pex_parent, modules):
return generator.render()

def _get_interpreter_for_target_closure(self, target):
targets = [t for t in target.closure() if isinstance(t, PythonTask)]
targets = [t for t in target.closure() if isinstance(t, PythonTarget)]
return self._interpreter_cache().select_interpreter_for_targets(targets)

def _resolve_requirements_for_versioned_target_closure(self, interpreter, vt):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
name='lib'
)

python_tests(
dependencies=[
':lib',
'contrib/python/src/python/pants/contrib/python/checks/tasks/checkstyle:all',
'src/python/pants/util:dirutil',
'tests/python/pants_test/backend/python/tasks:python_task_test_base',
Expand Down

0 comments on commit b486753

Please sign in to comment.