pyflightstream.extras (stable)¶
Generated from the docstrings at build time: every one of the 5 names in the __all__ of pyflightstream.extras has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Optional extras, their distributions and a shared missing-extra refusal.
Import-light support below every gated module: only the package base exception is required. MissingExtraError gives callers one exception type and constructs the remedy from the registered extra name. Tests compare that registry with pyproject.toml so the suggested install command names the distributions the gated code needs.
Used in the guides¶
pyflightstream.extras.MissingExtraError
¶
MissingExtraError(
*, extra: str, package: str, purpose: str
)
Bases: PyflightstreamError, ImportError
A code path needs an optional extra that is not installed.
One type for every extra, so except MissingExtraError handles
the whole class, and an ImportError second base so the clauses
that caught the old refusals keep catching this one.
Attributes:
| Name | Type | Description |
|---|---|---|
extra |
str
|
Name of the extra, as |
package |
str
|
The distribution or module that was actually missing. |
remedy |
str
|
The exact install command, composed from |
Advanced¶
pyflightstream.extras.EXTRAS
module-attribute
¶
EXTRAS: dict[str, tuple[str, ...]] = {
"pandas": ("pandas",),
"excel": ("XlsxWriter",),
"fsi": ("PyNiteFEA",),
"manual": ("pypdf",),
}
pyflightstream.extras.KernelUnavailableError
¶
KernelUnavailableError(*, purpose: str, reason: str)
Bases: MissingExtraError
The CAD kernel library is not installed or cannot load in this environment.
A :class:MissingExtraError, so a handler written for the missing extra still catches it.
It is raised for an ImportError and for an OSError (a shared library the kernel needs
failed to load, which import reports as OSError). The message names the library that
failed, from the original error, the Linux package line, and that the stages that build
surfaces without the kernel (S0 to S9) still run.
pyflightstream.extras.UnknownExtraError
¶
Bases: PyflightstreamError, ValueError
A name was used as an optional extra and this package has no such extra.
Raised at the refusal-building step rather than at import: naming a nonexistent extra would send the reader to an install command that fails, which is worse than the missing dependency it was trying to explain.
Also a ValueError for callers handling that exception family (FR-39).
pyflightstream.extras.missing_extra
¶
missing_extra(
extra: str, *, package: str, purpose: str
) -> MissingExtraError
Build the refusal for a missing extra, for a raise ... from.
A NOUN, not a check. It was called require_extra for one review
cycle, and that name promises a guard: written as a bare statement it
would build the exception, discard it and continue, with nothing in
the linter to notice. The failure mode of the misuse would have been
silence, which is the class this module exists to close.
Returns the exception rather than raising it, so the call site keeps
its raise ... from error and the original ImportError stays
in the chain: the underlying failure is often more specific than
"not installed" (a broken build, a missing shared library), and
discarding it turns a diagnosable problem into a pip suggestion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extra
|
str
|
Name of the extra; must be one of :data: |
required |
package
|
str
|
Distribution or module that failed to import. |
required |
purpose
|
str
|
What the caller was trying to do, as a sentence subject, for
example |
required |
Returns:
| Type | Description |
|---|---|
MissingExtraError
|
Ready to raise. |