CoffeaTeam / fsspec-xrootd

An XRootD implementation for fsspec
https://coffeateam.github.io/fsspec-xrootd/
BSD 3-Clause "New" or "Revised" License
3 stars 4 forks source link

remove default value for hostid parameter #26

Closed lobis closed 10 months ago

lobis commented 11 months ago

When playing around with fsspec I noticed that when you do not use the required arguments for the given filesystem (e.g. host for protocol="ftp") it throws a TypeError pointing you to the argument you are missing.

>>> import fsspec
>>> fsspec.filesystem(protocol="ftp")
Exception ignored in: <function FTPFileSystem.__del__ at 0x102251d00>
Traceback (most recent call last):
  File "/Users/lobis/miniconda3/envs/uproot-311/lib/python3.11/site-packages/fsspec/implementations/ftp.py", line 248, in __del__
    self.ftp.close()
    ^^^^^^^^
AttributeError: 'FTPFileSystem' object has no attribute 'ftp'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lobis/miniconda3/envs/uproot-311/lib/python3.11/site-packages/fsspec/registry.py", line 289, in filesystem
    return cls(**storage_options)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lobis/miniconda3/envs/uproot-311/lib/python3.11/site-packages/fsspec/spec.py", line 79, in __call__
    obj = super().__call__(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: FTPFileSystem.__init__() missing 1 required positional argument: 'host'

This PR removes the default value for the hostid parameter. With the default value of "" the instantiation was also giving an error but it was less descriptive and not in line with the other fsspec filesystems.

I also added a test to check the correct type of exception is thrown.

Behaviour after change:

>>> fsspec.filesystem(protocol="root")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lobis/miniconda3/envs/uproot-311/lib/python3.11/site-packages/fsspec/registry.py", line 289, in filesystem
    return cls(**storage_options)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lobis/miniconda3/envs/uproot-311/lib/python3.11/site-packages/fsspec/spec.py", line 79, in __call__
    obj = super().__call__(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: XRootDFileSystem.__init__() missing 1 required positional argument: 'hostid'
lobis commented 11 months ago

Looks like the failure comes from before this PR, I tried running the tests locally on the main branch and they appear to fail on the same step (which is weird).