biocommons / biocommons.seqrepo

non-redundant, compressed, journalled, file-based storage for biological sequences
Apache License 2.0
39 stars 35 forks source link

FabgzWriter file handler property is improperly initialized #159

Closed jsstevenson closed 5 months ago

jsstevenson commented 5 months ago

Describe the bug Pretty simple -- FabgzWriter initializes a self.fh property, when it should be self._fh. This can mess up the functioning of the __del__ method during some code paths, although I think the impact is minimal.

To Reproduce

Run the test cases (eg test_fabgz.py::test_errors)

tests/test_fabgz.py::test_errors                                                                                                                                                                                                                                                                     
  /Users/jss009/code/biocommons.seqrepo/.venv-312/lib/python3.12/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: <function FabgzWriter.__del__ at 0x107a83560>                                                                              

  Traceback (most recent call last):                                                                                                              
    File "/Users/jss009/code/biocommons.seqrepo/src/biocommons/seqrepo/fastadir/fabgz.py", line 173, in __del__                                                                                                                                                                                      
      if self._fh is not None:                                                                                                                                                                                                                                                                       
         ^^^^^^^^                                                                                                                                                                                                                                                                                    
  AttributeError: 'FabgzWriter' object has no attribute '_fh'. Did you mean: 'fh'?                                                                

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))                                                                                                                                                                                                                                      

Expected behavior The property should exist upon object destruction.