Changeset - 7783f7ad10b5
[Not reviewed]
0 3 0
Ben Sturmfels (bsturmfels) - 3 years ago 2022-02-04 08:11:59
ben@sturm.com.au
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"
3 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/core.py
Show inline comments
...
 
@@ -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',
conservancy_beancount/reports/ledger.py
Show inline comments
...
 
@@ -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(
conservancy_beancount/reports/rewrite.py
Show inline comments
...
 
@@ -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:
0 comments (0 inline, 0 general)