6565 S3ConfigInput ,
6666 )
6767
68- SUPPORTED_PROTOCOLS = {
68+ SUPPORTED_PROTOCOLS : set [ str ] = {
6969 "abfs" ,
7070 "abfss" ,
7171 "adl" ,
8080 "s3" ,
8181 "s3a" ,
8282}
83+ """All supported protocols."""
84+
85+ SUPPORTED_PROTOCOLS_T = Literal [
86+ "abfs" ,
87+ "abfss" ,
88+ "adl" ,
89+ "az" ,
90+ "azure" ,
91+ "file" ,
92+ "gcs" ,
93+ "gs" ,
94+ "http" ,
95+ "https" ,
96+ "memory" ,
97+ "s3" ,
98+ "s3a" ,
99+ ]
100+ """A type hint for all supported protocols."""
83101
84102
85103class FsspecStore (fsspec .asyn .AsyncFileSystem ):
@@ -747,24 +765,44 @@ def loc(self, value: int) -> None:
747765 raise ValueError ("Cannot set `.loc`. Use `seek` instead." )
748766
749767
750- def register (protocol : str | Iterable [str ], * , asynchronous : bool = False ) -> None :
768+ def register (
769+ protocol : SUPPORTED_PROTOCOLS_T
770+ | str
771+ | Iterable [SUPPORTED_PROTOCOLS_T ]
772+ | Iterable [str ]
773+ | None = None ,
774+ * ,
775+ asynchronous : bool = False ,
776+ ) -> None :
751777 """Dynamically register a subclass of FsspecStore for the given protocol(s).
752778
753779 This function creates a new subclass of FsspecStore with the specified
754780 protocol and registers it with fsspec. If multiple protocols are provided,
755781 the function registers each one individually.
756782
757783 Args:
758- protocol (str | list[str]): A single protocol (e.g., "s3", "gcs", "abfs") or
759- a list of protocols to register FsspecStore for.
760- asynchronous (bool, optional): If True, the registered store will support
761- asynchronous operations. Defaults to False.
784+ protocol: A single protocol (e.g., "s3", "gcs", "abfs") or
785+ a list of protocols to register FsspecStore for. Defaults to `None`, which
786+ will register `obstore` as the provider for all [supported
787+ protocols][obstore.fsspec.SUPPORTED_PROTOCOLS] **except** for `file://` and
788+ `memory://`. If you wish to use `obstore` via fsspec for `file://` or
789+ `memory://` URLs, list them explicitly.
790+ asynchronous: If `True`, the registered store will support
791+ asynchronous operations. Defaults to `False`.
762792
763793 Example:
764794 ```py
795+ # Register obstore as the default handler for all supported protocols except for
796+ # `memory://` and `file://`
797+ register()
798+
765799 register("s3")
766- register("s3", asynchronous=True) # Registers an async store for "s3"
767- register(["gcs", "abfs"]) # Registers both "gcs" and "abfs"
800+
801+ # Registers an async store for "s3"
802+ register("s3", asynchronous=True)
803+
804+ # Registers both "gcs" and "abfs"
805+ register(["gcs", "abfs"])
768806 ```
769807
770808 Notes:
@@ -773,6 +811,9 @@ def register(protocol: str | Iterable[str], *, asynchronous: bool = False) -> No
773811 FsspecStore class.
774812
775813 """
814+ if protocol is None :
815+ protocol = SUPPORTED_PROTOCOLS - {"file" , "memory" }
816+
776817 if isinstance (protocol , str ):
777818 _register (protocol , asynchronous = asynchronous )
778819 return
0 commit comments