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
|
Xuecong Liao
|
||||||
Yoav Caspi
|
Yoav Caspi
|
||||||
Zac Hatfield-Dodds
|
Zac Hatfield-Dodds
|
||||||
|
Zachary Kneupper
|
||||||
Zoltán Máté
|
Zoltán Máté
|
||||||
Zsolt Cserna
|
Zsolt Cserna
|
||||||
|
|
|
@ -100,10 +100,7 @@ def pre_release(version, *, skip_check_links):
|
||||||
|
|
||||||
|
|
||||||
def changelog(version, write_out=False):
|
def changelog(version, write_out=False):
|
||||||
if write_out:
|
addopts = [] if write_out else ["--draft"]
|
||||||
addopts = []
|
|
||||||
else:
|
|
||||||
addopts = ["--draft"]
|
|
||||||
check_call(["towncrier", "--yes", "--version", version] + addopts)
|
check_call(["towncrier", "--yes", "--version", version] + addopts)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -618,14 +618,8 @@ class MultiCapture(Generic[AnyStr]):
|
||||||
return self._state == "started"
|
return self._state == "started"
|
||||||
|
|
||||||
def readouterr(self) -> CaptureResult[AnyStr]:
|
def readouterr(self) -> CaptureResult[AnyStr]:
|
||||||
if self.out:
|
out = self.out.snap() if self.out else ""
|
||||||
out = self.out.snap()
|
err = self.err.snap() if self.err else ""
|
||||||
else:
|
|
||||||
out = ""
|
|
||||||
if self.err:
|
|
||||||
err = self.err.snap()
|
|
||||||
else:
|
|
||||||
err = ""
|
|
||||||
return CaptureResult(out, err)
|
return CaptureResult(out, err)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -647,10 +647,7 @@ def _init_checker_class() -> Type["doctest.OutputChecker"]:
|
||||||
exponent: Optional[str] = w.group("exponent1")
|
exponent: Optional[str] = w.group("exponent1")
|
||||||
if exponent is None:
|
if exponent is None:
|
||||||
exponent = w.group("exponent2")
|
exponent = w.group("exponent2")
|
||||||
if fraction is None:
|
precision = 0 if fraction is None else len(fraction)
|
||||||
precision = 0
|
|
||||||
else:
|
|
||||||
precision = len(fraction)
|
|
||||||
if exponent is not None:
|
if exponent is not None:
|
||||||
precision -= int(exponent)
|
precision -= int(exponent)
|
||||||
if float(w.group()) == approx(float(g.group()), abs=10 ** -precision):
|
if float(w.group()) == approx(float(g.group()), abs=10 ** -precision):
|
||||||
|
|
|
@ -669,10 +669,7 @@ class TerminalReporter:
|
||||||
skipped = len(self.stats.get("skipped", []))
|
skipped = len(self.stats.get("skipped", []))
|
||||||
deselected = len(self.stats.get("deselected", []))
|
deselected = len(self.stats.get("deselected", []))
|
||||||
selected = self._numcollected - errors - skipped - deselected
|
selected = self._numcollected - errors - skipped - deselected
|
||||||
if final:
|
line = "collected " if final else "collecting "
|
||||||
line = "collected "
|
|
||||||
else:
|
|
||||||
line = "collecting "
|
|
||||||
line += (
|
line += (
|
||||||
str(self._numcollected) + " item" + ("" if self._numcollected == 1 else "s")
|
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:
|
with catch_threading_exception() as cm:
|
||||||
yield
|
yield
|
||||||
if cm.args:
|
if cm.args:
|
||||||
if cm.args.thread is not None:
|
thread_name = "<unknown>" if cm.args.thread is None else cm.args.thread.name
|
||||||
thread_name = cm.args.thread.name
|
|
||||||
else:
|
|
||||||
thread_name = "<unknown>"
|
|
||||||
msg = f"Exception in thread {thread_name}\n\n"
|
msg = f"Exception in thread {thread_name}\n\n"
|
||||||
msg += "".join(
|
msg += "".join(
|
||||||
traceback.format_exception(
|
traceback.format_exception(
|
||||||
|
|
Loading…
Reference in New Issue