Replaced if-else statements with ternary expression (#8658)
* Replace if-else with ternary expression * assign out variable in readouterr() with ternary expression * assign err variable in readouterr() with ternary expression * Assign precision with ternary expression * ternary expression for collected/collecting * Assign thread_name with ternary expression * Update AUTHORS Co-authored-by: Zachary Kneupper <zacharykneupper@Zacharys-MBP.lan>
This commit is contained in:
parent
7cec85a37d
commit
045ad5ac2d
1
AUTHORS
1
AUTHORS
|
@ -333,5 +333,6 @@ Xuan Luong
|
|||
Xuecong Liao
|
||||
Yoav Caspi
|
||||
Zac Hatfield-Dodds
|
||||
Zachary Kneupper
|
||||
Zoltán Máté
|
||||
Zsolt Cserna
|
||||
|
|
|
@ -100,10 +100,7 @@ def pre_release(version, *, skip_check_links):
|
|||
|
||||
|
||||
def changelog(version, write_out=False):
|
||||
if write_out:
|
||||
addopts = []
|
||||
else:
|
||||
addopts = ["--draft"]
|
||||
addopts = [] if write_out else ["--draft"]
|
||||
check_call(["towncrier", "--yes", "--version", version] + addopts)
|
||||
|
||||
|
||||
|
|
|
@ -618,14 +618,8 @@ class MultiCapture(Generic[AnyStr]):
|
|||
return self._state == "started"
|
||||
|
||||
def readouterr(self) -> CaptureResult[AnyStr]:
|
||||
if self.out:
|
||||
out = self.out.snap()
|
||||
else:
|
||||
out = ""
|
||||
if self.err:
|
||||
err = self.err.snap()
|
||||
else:
|
||||
err = ""
|
||||
out = self.out.snap() if self.out else ""
|
||||
err = self.err.snap() if self.err else ""
|
||||
return CaptureResult(out, err)
|
||||
|
||||
|
||||
|
|
|
@ -647,10 +647,7 @@ def _init_checker_class() -> Type["doctest.OutputChecker"]:
|
|||
exponent: Optional[str] = w.group("exponent1")
|
||||
if exponent is None:
|
||||
exponent = w.group("exponent2")
|
||||
if fraction is None:
|
||||
precision = 0
|
||||
else:
|
||||
precision = len(fraction)
|
||||
precision = 0 if fraction is None else len(fraction)
|
||||
if exponent is not None:
|
||||
precision -= int(exponent)
|
||||
if float(w.group()) == approx(float(g.group()), abs=10 ** -precision):
|
||||
|
|
|
@ -669,10 +669,7 @@ class TerminalReporter:
|
|||
skipped = len(self.stats.get("skipped", []))
|
||||
deselected = len(self.stats.get("deselected", []))
|
||||
selected = self._numcollected - errors - skipped - deselected
|
||||
if final:
|
||||
line = "collected "
|
||||
else:
|
||||
line = "collecting "
|
||||
line = "collected " if final else "collecting "
|
||||
line += (
|
||||
str(self._numcollected) + " item" + ("" if self._numcollected == 1 else "s")
|
||||
)
|
||||
|
|
|
@ -61,10 +61,7 @@ def thread_exception_runtest_hook() -> Generator[None, None, None]:
|
|||
with catch_threading_exception() as cm:
|
||||
yield
|
||||
if cm.args:
|
||||
if cm.args.thread is not None:
|
||||
thread_name = cm.args.thread.name
|
||||
else:
|
||||
thread_name = "<unknown>"
|
||||
thread_name = "<unknown>" if cm.args.thread is None else cm.args.thread.name
|
||||
msg = f"Exception in thread {thread_name}\n\n"
|
||||
msg += "".join(
|
||||
traceback.format_exception(
|
||||
|
|
Loading…
Reference in New Issue