Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed Sep 4, 2023
1 parent c9fb307 commit b7be436
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pyhepmc/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ class HepMCFile:
IOError if reading or writing fails.
"""

_reader: Optional[ReaderMixin]
_writer: Optional[Union[WriterAscii, WriterAsciiHepMC2, WriterHEPEVT]]

def __init__(
self,
fileobj: Filename,
Expand Down Expand Up @@ -246,8 +249,7 @@ def __init__(

mode += "b"

def open_file() -> Any:
return open(fn, mode)
open_file = lambda: open(fn, mode) # noqa: E731

self._close_file = True

Expand Down Expand Up @@ -310,6 +312,7 @@ def open_file() -> Any:
__exit__ = _exit_close

def __iter__(self) -> Any:
assert self._reader is not None
return self._reader.__iter__()

def flush(self) -> None:
Expand Down

0 comments on commit b7be436

Please sign in to comment.