Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CsvLineSpooler.next() falls through to Nos(None).exists() instead of returning early when path is unset #195

Copy link
Copy link

Description

@dk107dk
Issue body actions

In csvpath/util/line_spooler.py, CsvLineSpooler.next() starts with:

def next(self):
    if not self.path:
        ...
    if Nos(self.path).exists() is False:

The "if not self.path: ..." line uses the Ellipsis placeholder as a no-op instead of an actual early return. to_list(), the sibling method right above it, handles the same situation correctly:

def to_list(self) -> list[str]:
    if not self.path:
        return []

Because next() does not return, when path is falsy it falls through to Nos(self.path).exists(), i.e. Nos(None).exists(). Nos.do raises ValueError("Do cannot be None. Path is: None") when path is None, since there is no backend to route to. So calling next() before a data file path is available raises ValueError instead of yielding nothing.

Left a TODO in next() (see branch test/util-line-monitor-io-spooler) rather than fixing directly, since this touches Result/instance-dir plumbing that intersects with run_home_maker.py, which David has flagged as sensitive and wants extra caution around. The TODO notes that the eventual fix should add a return type hint and return None (not []) for the no-path case, distinct from to_list(), though that may be reconsidered when this is revisited.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.