Skip to content

Commit

Permalink
chore: fix linting errors on Windows and CI checks
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Usiskin <[email protected]>
  • Loading branch information
jusiskin committed Nov 15, 2024
1 parent c9186bb commit a1eeb1d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ fail_under = 79
# https://github.com/wemake-services/coverage-conditional-plugin
[tool.coverage.coverage_conditional_plugin.omit]
"sys_platform != 'win32'" = [
"src/openjd/sessions/_linux/*.py",
"src/openjd/sessions/_win32/*.py",
"src/openjd/sessions/_scripts/_windows/*.py",
"src/openjd/sessions/_windows*.py"
]
"sys_platform == 'win32'" = [
"src/openjd/sessions/_linux/*.py",
]

[tool.coverage.coverage_conditional_plugin.rules]
# This cannot be empty otherwise coverage-conditional-plugin crashes with:
Expand Down
10 changes: 8 additions & 2 deletions src/openjd/sessions/_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def _find_sudo_child_process_ids(
*,
timeout_seconds: float = 1,
) -> Optional[SudoChildProcessIDs]:
# Hint to mypy to not raise module attribute errors (e.g. missing os.getpgid)
if sys.platform == "win32":
raise NotImplementedError("This method is for POSIX hosts only")
process = self._process
if process is None:
raise ValueError("Process not launched")
Expand Down Expand Up @@ -593,6 +596,10 @@ def _posix_signal_subprocess(
) -> None:
"""Send a given named signal to the subprocess."""

# Hint to mypy to not raise module attribute errors (e.g. missing os.getpgid)
if sys.platform == "win32":
raise NotImplementedError("This method is for POSIX hosts only")

# We can run into a race condition where the process exits (and another thread sets self._process to None)
# before the cancellation happens, so we swap to a local variable to ensure a cancellation that is not needed,
# does not raise an exception here.
Expand Down Expand Up @@ -633,8 +640,7 @@ def _posix_signal_subprocess(
f"INTERRUPT: Unable to send {signal_name} to {process.pid}",
extra=LogExtraInfo(openjd_log_content=LogContent.PROCESS_CONTROL),
)
finally:
return
return
elif signal_name == "kill":
numeric_signal = signal.SIGKILL
else:
Expand Down
2 changes: 1 addition & 1 deletion testing_containers/localuser_sudo_environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ENV PIP_INDEX_URL=$PIP_INDEX_URL
# hostuser: hostuser, sharedgroup
# targetuser: targetuser, sharedgroup
# disjointuser: disjointuser, disjointgroup
RUN apt-get update && apt-get install -y sudo psmisc libcap2-bin libcap2 libcap-dev gcc && \
RUN apt-get update && apt-get install -y libcap2-bin libcap2 libcap-dev gcc psmisc sudo && \

Check notice

Code scanning / SonarCloud

Arguments in long RUN instructions should be sorted Low test

Sort these package names alphanumerically. See more on SonarQube Cloud
# Clean up apt cache
rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
Expand Down

0 comments on commit a1eeb1d

Please sign in to comment.