Skip to content

Commit

Permalink
Merge branch 'master' into cottsay/no-cov-subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
cottsay committed Sep 13, 2023
2 parents 4f443be + 3241f1c commit a96e7ec
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion colcon_core/package_augmentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def update_metadata(desc, key, value):
old_value |= value
return

if type(old_value) != type(value):
if type(old_value) is not type(value):
logger.warning(
f"update package '{desc.name}' metadata '{key}' from value "
f"'{old_value}' to '{value}'")
Expand Down
2 changes: 1 addition & 1 deletion colcon_core/package_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __hash__(self): # noqa: D105
return hash((self.type, self.name))

def __eq__(self, other): # noqa: D105
if type(self) != type(other):
if type(self) is not type(other):
return NotImplemented
if (self.type, self.name) != (other.type, other.name):
return False
Expand Down
18 changes: 11 additions & 7 deletions colcon_core/task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ async def check_call(


async def run(
context, cmd, *, cwd=None, env=None, shell=False, use_pty=None,
capture_output=None
context, cmd, *, use_pty=None, capture_output=None, **other_popen_kwargs
):
"""
Run the command described by cmd.
Expand All @@ -159,10 +158,11 @@ async def run(
All output to `stdout` and `stderr` is posted as `StdoutLine` and
`StderrLine` events to the event queue.
See the documentation of `subprocess.Popen()
<https://docs.python.org/3/library/subprocess.html#subprocess.Popen>` for
other parameters.
:param cmd: The command and its arguments
:param cwd: the working directory for the subprocess
:param env: a dictionary with environment variables
:param shell: whether to use the shell as the program to execute
:param use_pty: whether to use a pseudo terminal
:param capture_output: whether to store stdout and stderr
:returns: the result of the completed process
Expand All @@ -174,12 +174,16 @@ def stdout_callback(line):
def stderr_callback(line):
context.put_event_into_queue(StderrLine(line))

cwd = other_popen_kwargs.get('cwd', None)
env = other_popen_kwargs.get('env', None)
shell = other_popen_kwargs.get('shell', False)

context.put_event_into_queue(
Command(cmd, cwd=cwd, env=env, shell=shell))
completed = await colcon_core_subprocess_run(
cmd, stdout_callback, stderr_callback,
cwd=cwd, env=env, shell=shell, use_pty=use_pty,
capture_output=capture_output)
use_pty=use_pty, capture_output=capture_output,
**other_popen_kwargs)
context.put_event_into_queue(
CommandEnded(
cmd, cwd=cwd, env=env, shell=shell,
Expand Down
2 changes: 1 addition & 1 deletion colcon_core/verb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def update_object(
return

severity = 5 \
if old_value is None or type(old_value) == type(value) \
if old_value is None or type(old_value) is type(value) \
else logging.WARNING
logger.log(
severity, f"overwrite package '{package_name}' {argument_type} "
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ filterwarnings =
ignore:The loop argument is deprecated::asyncio
ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated::pydocstyle
ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated::pyreadline
# Suppress resource warnings pending investigation
always::ResourceWarning
junit_suite_name = colcon-core
markers =
flake8
linter
python_classes = !TestFailure

[options.entry_points]
Expand Down
1 change: 1 addition & 0 deletions test/spell_check.words
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ junit
levelname
libexec
lineno
linter
linux
lstrip
mkdtemp
Expand Down
4 changes: 2 additions & 2 deletions test/test_argument_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def test_argument_default():
unwrap_default_value(value)
default_value = wrap_default_value(value)
assert is_default_value(default_value)
assert type(default_value) != type(value)
assert type(default_value) is not type(value)
with pytest.raises(ValueError):
wrap_default_value(default_value)
unwrapped_value = unwrap_default_value(default_value)
assert value == unwrapped_value

value = 42
unchanged_value = wrap_default_value(value)
assert type(unchanged_value) == type(value)
assert type(unchanged_value) is type(value)
assert unchanged_value == value
3 changes: 3 additions & 0 deletions test/test_copyright_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from pathlib import Path
import sys

import pytest


@pytest.mark.linter
def test_copyright_license():
missing = check_files([
Path(__file__).parents[1],
Expand Down
15 changes: 8 additions & 7 deletions test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
from pathlib import Path
import sys

from flake8 import LOG
from flake8.api.legacy import get_style_guide
from pydocstyle.utils import log
import pytest


# avoid debug / info / warning messages from flake8 internals
LOG.setLevel(logging.ERROR)
@pytest.mark.flake8
@pytest.mark.linter
def test_flake8():
from flake8.api.legacy import get_style_guide

# avoid debug / info / warning messages from flake8 internals
logging.getLogger('flake8').setLevel(logging.ERROR)

def test_flake8():
# for some reason the pydocstyle logger changes to an effective level of 1
# set higher level to prevent the output to be flooded with debug messages
log.setLevel(logging.WARNING)
logging.getLogger('pydocstyle').setLevel(logging.WARNING)

style_guide = get_style_guide(
extend_ignore=['D100', 'D104'],
Expand Down
11 changes: 7 additions & 4 deletions test/test_spell_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
from pathlib import Path

import pytest
from scspell import Report
from scspell import SCSPELL_BUILTIN_DICT
from scspell import spell_check


spell_check_words_path = Path(__file__).parent / 'spell_check.words'

Expand All @@ -18,7 +14,12 @@ def known_words():
return spell_check_words_path.read_text().splitlines()


@pytest.mark.linter
def test_spell_check(known_words):
from scspell import Report
from scspell import SCSPELL_BUILTIN_DICT
from scspell import spell_check

source_filenames = [
Path(__file__).parents[1] / 'bin' / 'colcon',
Path(__file__).parents[1] / 'setup.py'] + \
Expand Down Expand Up @@ -46,11 +47,13 @@ def test_spell_check(known_words):
', '.join(sorted(unused_known_words))


@pytest.mark.linter
def test_spell_check_word_list_order(known_words):
assert known_words == sorted(known_words), \
'The word list should be ordered alphabetically'


@pytest.mark.linter
def test_spell_check_word_list_duplicates(known_words):
assert len(known_words) == len(set(known_words)), \
'The word list should not contain duplicates'

0 comments on commit a96e7ec

Please sign in to comment.