8000 rfctr: improve expression · python-openxml/python-docx@d8a3289 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8a3289

Browse files
committed
rfctr: improve expression
1 parent cf5286c commit d8a3289

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/docx/oxml/table.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,7 @@ def grid_span(self) -> int:
441441
Determined by ./w:tcPr/w:gridSpan/@val, it defaults to 1.
442442
"""
443443
tcPr = self.tcPr
444-
if tcPr is None:
445-
return 1
446-
return tcPr.grid_span
444+
return 1 if tcPr is None else tcPr.grid_span
447445

448446
@grid_span.setter
449447
def grid_span(self, value: int):
@@ -809,9 +807,7 @@ def grid_span(self) -> int:
809807
Determined by ./w:gridSpan/@val, it defaults to 1.
810808
"""
811809
gridSpan = self.gridSpan
812-
if gridSpan is None:
813-
return 1
814-
return gridSpan.val
810+
return 1 if gridSpan is None else gridSpan.val
815811

816812
@grid_span.setter
817813
def grid_span(self, value: int):
@@ -898,9 +894,7 @@ class CT_TrPr(BaseOxmlElement):
898894
def trHeight_hRule(self) -> WD_ROW_HEIGHT_RULE | None:
899895
"""Return the value of `w:trHeight@w:hRule`, or |None| if not present."""
900896
trHeight = self.trHeight
901-
if trHeight is None:
902-
return None
903-
return trHeight.hRule
897+
return None if trHeight is None else trHeight.hRule
904898

905899
@trHeight_hRule.setter
906900
def trHeight_hRule(self, value: WD_ROW_HEIGHT_RULE | None):
@@ -913,9 +907,7 @@ def trHeight_hRule(self, value: WD_ROW_HEIGHT_RULE | None):
913907
def trHeight_val(self):
914908
"""Return the value of `w:trHeight@w:val`, or |None| if not present."""
915909
trHeight = self.trHeight
916-
if trHeight is None:
917-
return None
918-
return trHeight.val
910+
return None if trHeight is None else trHeight.val
919911

920912
@trHeight_val.setter
921913
def trHeight_val(self, value: Length | None):

0 commit comments

Comments
 (0)
0