Unverified Commit 9d0a2009 authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #17445 from nuwang/make_extra_props_more_defensive

More defensive access of extra props in filesources
parents 7bffadb6 c7a5e4ff
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
import abc
import os
import time
from dataclasses import (
    dataclass,
    field,
)
from typing import (
    Any,
    ClassVar,
@@ -52,14 +56,20 @@ class FilesSourceProperties(TypedDict):
    browsable: NotRequired[bool]


@dataclass
class FilesSourceOptions:
    """Options to control behaviour of filesource operations, such as realize_to and write_from"""
    """Options to control behavior of file source operations, such as realize_to, write_from and list."""

    # Indicates access to the FS operation with intent to write.
    # Even if a file source is "writeable" some directories (or elements) may be restricted or read-only
    # so those should be skipped while browsing with writeable=True.
    writeable: Optional[bool] = False

    # Property overrides for values initially configured through the constructor. For example
    # the HTTPFilesSource passes in additional http_headers through these properties, which
    # are merged with constructor defined http_headers. The interpretation of these properties
    # are filesystem specific.
    extra_props: Optional[FilesSourceProperties]
    extra_props: Optional[FilesSourceProperties] = field(default_factory=lambda: FilesSourceProperties())


class SingleFileSource(metaclass=abc.ABCMeta):