Skip to content

Commit 165c033

Browse files
rotudirk-thomas
andauthored
rename rc -> completed (#235)
* rename rc -> completed Also, don't check if check_call returns None. It never does. * return rc from _undo_develop * document return type * use completed for returned value Co-authored-by: Dirk Thomas <[email protected]>
1 parent 91bbad2 commit 165c033

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

colcon_core/subprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ async def run(
6666
:param shell: whether to use the shell as the program to execute
6767
:param use_pty: whether to use a pseudo terminal
6868
:returns: the result of the completed process
69+
:rtype subprocess.CompletedProcess
6970
"""
7071
assert callable(stdout_callback) or stdout_callback is None
7172
assert callable(stderr_callback) or stderr_callback is None

colcon_core/task/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ async def check_call(
135135
:param shell: whether to use the shell as the program to execute
136136
:param use_pty: whether to use a pseudo terminal
137137
:returns: the result of the completed process
138+
:rtype subprocess.CompletedProcess
138139
"""
139140
def stdout_callback(line):
140141
context.put_event_into_queue(StdoutLine(line))
@@ -144,13 +145,14 @@ def stderr_callback(line):
144145

145146
context.put_event_into_queue(
146147
Command(cmd, cwd=cwd, env=env, shell=shell))
147-
rc = await run(
148+
completed = await run(
148149
cmd, stdout_callback, stderr_callback,
149150
cwd=cwd, env=env, shell=shell, use_pty=use_pty)
150151
context.put_event_into_queue(
151152
CommandEnded(
152-
cmd, cwd=cwd, env=env, shell=shell, returncode=rc.returncode))
153-
return rc
153+
cmd, cwd=cwd, env=env, shell=shell,
154+
returncode=completed.returncode))
155+
return completed
154156

155157

156158
def get_task_extensions(task_name, *, unique_instance=False):

colcon_core/task/python/build.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ async def build(self, *, additional_hooks=None): # noqa: D102
5757

5858
if not args.symlink_install:
5959
rc = await self._undo_develop(pkg, args, env)
60-
if rc and rc.returncode:
61-
return rc.returncode
60+
if rc:
61+
return rc
6262

6363
# invoke `setup.py install` step with lots of arguments
6464
# to avoid placing any files in the source space
@@ -73,9 +73,10 @@ async def build(self, *, additional_hooks=None): # noqa: D102
7373
'--single-version-externally-managed',
7474
]
7575
self._append_install_layout(args, cmd)
76-
rc = await check_call(self.context, cmd, cwd=args.path, env=env)
77-
if rc and rc.returncode:
78-
return rc.returncode
76+
completed = await check_call(
77+
self.context, cmd, cwd=args.path, env=env)
78+
if completed.returncode:
79+
return completed.returncode
7980

8081
else:
8182
self._undo_install(pkg, args, setup_py_data, python_lib)
@@ -96,10 +97,10 @@ async def build(self, *, additional_hooks=None): # noqa: D102
9697
if setup_py_data.get('data_files'):
9798
cmd += ['install_data', '--install-dir', args.install_base]
9899
self._append_install_layout(args, cmd)
99-
rc = await check_call(
100+
completed = await check_call(
100101
self.context, cmd, cwd=args.build_base, env=env)
101-
if rc and rc.returncode:
102-
return rc.returncode
102+
if completed.returncode:
103+
return completed.returncode
103104

104105
# explicitly add the build directory to the PYTHONPATH
105106
# to maintain the desired order
@@ -131,10 +132,9 @@ async def _undo_develop(self, pkg, args, env):
131132
'--uninstall', '--editable',
132133
'--build-directory', os.path.join(args.build_base, 'build')
133134
]
134-
rc = await check_call(
135+
completed = await check_call(
135136
self.context, cmd, cwd=args.build_base, env=env)
136-
if rc:
137-
return rc
137+
return completed.returncode
138138

139139
def _undo_install(self, pkg, args, setup_py_data, python_lib):
140140
# undo previous install if install.log is found

colcon_core/task/python/test/pytest.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ async def step(self, context, env, setup_py_data): # noqa: D102
156156
</testsuite>
157157
""".format_map(locals())) # noqa: E501
158158

159-
rc = await check_call(context, cmd, cwd=context.args.path, env=env)
159+
completed = await check_call(
160+
context, cmd, cwd=context.args.path, env=env)
160161

161162
# use local import to avoid a dependency on pytest
162163
try:
@@ -166,7 +167,7 @@ async def step(self, context, env, setup_py_data): # noqa: D102
166167
# support pytest < 5.0
167168
from _pytest.main import EXIT_TESTSFAILED
168169
EXIT_CODE_TESTS_FAILED = EXIT_TESTSFAILED # noqa: N806
169-
if rc and rc.returncode == EXIT_CODE_TESTS_FAILED:
170+
if completed.returncode == EXIT_CODE_TESTS_FAILED:
170171
context.put_event_into_queue(
171172
TestFailure(context.pkg.name))
172173

@@ -177,7 +178,7 @@ async def step(self, context, env, setup_py_data): # noqa: D102
177178
# support pytest < 5.0
178179
from _pytest.main import EXIT_NOTESTSCOLLECTED
179180
EXIT_CODE_NO_TESTS = EXIT_NOTESTSCOLLECTED # noqa: N806
180-
if rc and rc.returncode not in (
181+
if completed.returncode not in (
181182
EXIT_CODE_NO_TESTS, EXIT_CODE_TESTS_FAILED
182183
):
183-
return rc.returncode
184+
return completed.returncode

colcon_core/task/python/test/setuppy_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ async def step(self, context, env, setup_py_data): # noqa: D102
4545
cmd = [executable, '-m', 'unittest', '-v']
4646
if context.args.unittest_args is not None:
4747
cmd += context.args.unittest_args
48-
rc = await check_call(context, cmd, cwd=context.args.path, env=env)
49-
if rc and rc.returncode:
50-
return rc.returncode
48+
completed = await check_call(
49+
context, cmd, cwd=context.args.path, env=env)
50+
return completed.returncode

0 commit comments

Comments
 (0)