Skip to content

FileWatchConfig

Base classes

Name Children Inherits
EventSourceConfig
evented_config.configs
Base configuration for event sources.

⋔ Inheritance diagram

graph TD
  3205037684["configs.FileWatchConfig"]
  711273161["configs.EventSourceConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  711273161 --> 3205037684
  330168112 --> 711273161
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: EventSourceConfig

File watching event source.

Source code in src/evented_config/configs.py
class FileWatchConfig(EventSourceConfig):
    """File watching event source."""

    type: Literal["file"] = Field("file", init=False)
    """File / folder content change events."""

    paths: list[str] = Field(
        examples=[["./src", "./docs"], ["/home/user/projects"], ["*.py", "config/*.yaml"]],
        title="Watch paths",
    )
    """Paths or patterns to watch for changes."""

    extensions: list[str] | None = Field(
        default=None,
        examples=[[".py", ".md"], [".js", ".ts", ".json"], [".yaml", ".yml"]],
        title="File extensions",
    )
    """File extensions to monitor (e.g. ['.py', '.md'])."""

    ignore_paths: list[str] | None = Field(
        default=None,
        examples=[["__pycache__", ".git"], ["node_modules"], ["*.tmp"]],
        title="Ignore patterns",
    )
    """Paths or patterns to ignore."""

    recursive: bool = Field(default=True, title="Recursive watching")
    """Whether to watch subdirectories."""

    debounce: int = Field(
        default=1600,
        gt=0,
        examples=[500, 1600, 3000],
        title="Debounce delay (ms)",
    )
    """Minimum time (ms) between trigger events."""

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "File watching"})

    def get_event_source(self) -> FileSystemEventSource:
        """Create file system event source instance."""
        from evented.file_watcher import FileSystemEventSource

        return FileSystemEventSource(config=self)

debounce class-attribute instance-attribute

debounce: int = Field(default=1600, gt=0, examples=[500, 1600, 3000], title='Debounce delay (ms)')

Minimum time (ms) between trigger events.

extensions class-attribute instance-attribute

extensions: list[str] | None = Field(
    default=None,
    examples=[[".py", ".md"], [".js", ".ts", ".json"], [".yaml", ".yml"]],
    title="File extensions",
)

File extensions to monitor (e.g. ['.py', '.md']).

ignore_paths class-attribute instance-attribute

ignore_paths: list[str] | None = Field(
    default=None,
    examples=[["__pycache__", ".git"], ["node_modules"], ["*.tmp"]],
    title="Ignore patterns",
)

Paths or patterns to ignore.

paths class-attribute instance-attribute

paths: list[str] = Field(
    examples=[["./src", "./docs"], ["/home/user/projects"], ["*.py", "config/*.yaml"]],
    title="Watch paths",
)

Paths or patterns to watch for changes.

recursive class-attribute instance-attribute

recursive: bool = Field(default=True, title='Recursive watching')

Whether to watch subdirectories.

type class-attribute instance-attribute

type: Literal['file'] = Field('file', init=False)

File / folder content change events.

get_event_source

get_event_source() -> FileSystemEventSource

Create file system event source instance.

Source code in src/evented_config/configs.py
def get_event_source(self) -> FileSystemEventSource:
    """Create file system event source instance."""
    from evented.file_watcher import FileSystemEventSource

    return FileSystemEventSource(config=self)

:fa-brands-github: Show source on GitHub