fix(tests): Fix false positives for test_run_crash_anonymity
The test `test_run_crash_anonymity` can fail if the user or host name is
short:
```
======================================================================
FAIL: test_run_crash_anonymity (tests.integration.test_ui.T)
run_crash() anonymization
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.10/unittest/mock.py", line 1369, in patched
return func(*newargs, **newkeywargs)
File "/<<PKGBUILDDIR>>/tests/integration/test_ui.py", line 1650, in test_run_crash_anonymity
self.assertNotIn(
AssertionError: 'kin' unexpectedly found in 'ProblemType: Crash\nArchitecture: amd64\n[...]'
```
The string `kin` can be found in the report (for example in the tag
`kinetic`). So only search for full words in the report if the string is
short (less than five characters and not the string `ubuntu`).
Signed-off-by: Benjamin Drung <email address hidden>
fix: Fix raising OSError if _command_output() runs into a timeout
mypy complains:
```
apport/report.py:179: error: On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"; use "{!r}" if this is desired behavior [str-bytes-safe]
apport/report.py:180: error: Item "None" of "Optional[bytes]" has no attribute "rstrip" [union-attr]
```
The mypy complains can be converted into a test case that fail:
```
ERROR: test_command_output_timeout_no_output (tests.integration.test_report.T.test_command_output_timeout_no_output)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bdrung/projects/apport/apport/apport/report.py", line 169, in _command_output
sp = subprocess.run( ^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 550, in run
stdout, stderr = process.communicate(input, timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 1207, in communicate
stdout, stderr = self._communicate(input, endtime, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 2060, in _communicate
self._check_timeout(endtime, orig_timeout, stdout, stderr)
File "/usr/lib/python3.11/subprocess.py", line 1251, in _check_timeout
raise TimeoutExpired(
subprocess.TimeoutExpired: Command '['sleep', '3600']' timed out after 0.1 seconds
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bdrung/projects/apport/apport/tests/integration/test_report.py", line 1938, in test_command_output_timeout_no_output
apport.report._command_output(["sleep", "3600"], timeout=0.1)
File "/home/bdrung/projects/apport/apport/apport/report.py", line 182, in _command_output
f" after {error.timeout} seconds: {error.stdout.rstrip()}" ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'rstrip'
```
Signed-off-by: Benjamin Drung <email address hidden>
refactor: Move pylint's invalid-name overrides to affected files
Move pylint's invalid-name overrides to affected files to allow getting
this alert for new cases. Address the pylint complains for files that
only have a few complains.
Signed-off-by: Benjamin Drung <email address hidden>
refactor(gtk/kde): Add assertions to make mypy happy
mypy complains:
```
gtk/apport-gtk:238: error: "None" has no attribute "get" [attr-defined]
gtk/apport-gtk:280: error: Value of type "None" is not indexable [index]
gtk/apport-gtk:413: error: Unsupported right operand type for in ("None") [operator]
gtk/apport-gtk:414: error: Value of type "None" is not indexable [index]
kde/apport-kde:130: error: "QObject" has no attribute "setRange" [attr-defined]
kde/apport-kde:131: error: "QObject" has no attribute "setValue" [attr-defined]
kde/apport-kde:133: error: "QObject" has no attribute "setRange" [attr-defined]
kde/apport-kde:134: error: "QObject" has no attribute "setValue" [attr-defined]
kde/apport-kde:413: error: Incompatible types in assignment (expression has type "ReportDialog", variable has type "None") [assignment]
kde/apport-kde:417: error: "None" has no attribute "exec_" [attr-defined]
kde/apport-kde:426: error: "None" has no attribute "continue_button" [attr-defined]
kde/apport-kde:429: error: "None" has no attribute "send_error_report" [attr-defined]
kde/apport-kde:431: error: "None" has no attribute "ignore_future_problems" [attr-defined]
kde/apport-kde:516: error: "None" has no attribute "set" [attr-defined]
kde/apport-kde:518: error: "None" has no attribute "set" [attr-defined]
```
Add assertions to ensure that the variables are not `None`.
Signed-off-by: Benjamin Drung <email address hidden>