reports: Fix mypy errors.

Errors were:

  conservancy_beancount/reports/core.py:923: error: Generator has incompatible
  item type "Optional[str]"; expected "str"

  conservancy_beancount/reports/core.py:929: error: Item "None" of
  "Optional[str]" has no attribute "lower"

  conservancy_beancount/reports/ledger.py:534: error: Item "None" of
  "Optional[str]" has no attribute "partition"

  conservancy_beancount/reports/ledger.py:729: error: Item "None" of
  "Optional[str]" has no attribute "lower"

  conservancy_beancount/reports/rewrite.py:563: error: Argument 2 to
  "_iter_yaml" of "RewriteRuleset" has incompatible type "Union[Any, str,
  None]"; expected "str"
This commit is contained in:
Ben Sturmfels 2022-02-04 16:51:54 +11:00
parent 0342c5b83e
commit 7783f7ad10
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
3 changed files with 5 additions and 5 deletions

View file

@ -920,13 +920,13 @@ class BaseODS(BaseSpreadsheet[RT, ST], metaclass=abc.ABCMeta):
if not flags:
raise ValueError(f"no valid edges in {edges!r}")
border_attr = f'{width} {style} {color}'
key = f'{",".join(f.name for f in flags)} {border_attr}'
key = f'{",".join(str(f.name) for f in flags)} {border_attr}'
try:
retval = self._style_cache[key]
except KeyError:
props = odf.style.TableCellProperties()
for flag in flags:
props.setAttribute(f'border{flag.name.lower()}', border_attr)
props.setAttribute(f'border{str(flag.name).lower()}', border_attr)
retval = odf.style.Style(
name=f'Border{next(self._name_counter)}',
family='table-cell',

View file

@ -531,7 +531,7 @@ class ReportType(enum.IntFlag):
return cls.DEBIT_TRANSACTIONS
def _choices_sortkey(self) -> Sortable:
subtype, _, maintype = self.name.partition('_')
subtype, _, maintype = str(self.name).partition('_')
return (maintype, subtype)
@ -726,7 +726,7 @@ date was also not specified.
type=report_type.enum_type,
default=report_type_default,
help=f"""The type of report to generate. Choices are
{report_type.choices_str()}. Default is {report_type_default.name.lower()!r}.
{report_type.choices_str()}. Default is {str(report_type_default.name).lower()!r}.
""")
# --transactions got merged into --report-type; this is backwards compatibility.
parser.add_argument(

View file

@ -553,7 +553,7 @@ class RewriteRuleset:
if isinstance(source, str):
name = '<string>'
else:
name = getattr(source, 'name', '<file>')
name = str(getattr(source, 'name', '<file>'))
try:
doc = yaml.safe_load(source)
except yaml.error.YAMLError as error: