Improve API documentation about typing
This also removes the redundant type annotations from the API example. I think they make it harder to understand.
This commit is contained in:
parent
9157e65be1
commit
c0b2ac4fec
2 changed files with 18 additions and 8 deletions
|
|
@ -114,17 +114,23 @@ This example shows how to load the configuration and preform a basic query.
|
|||
# fedrq whatrequires --arch=noarch -b rawhide -r buildroot bash | grep '^a'
|
||||
|
||||
from fedrq.config import get_config, RQConfig
|
||||
from fedrq.backends.base import RepoqueryBase
|
||||
|
||||
# The get_config() function returns an RqConfig object.
|
||||
#
|
||||
# Load config from filesystem and override some options
|
||||
config: RQConfig = get_config(backend="libdnf5")
|
||||
config = get_config(backend="libdnf5")
|
||||
|
||||
# Query the Fedora Rawhide koji buildroot repositories
|
||||
# This supports any release configuration builtin to fedrq
|
||||
# The RQConfig.get_rq() method returns a Repoquery object.
|
||||
# Repoquery is fedrq's helper class to perform various types of package queries.
|
||||
#
|
||||
# This creates a Repoquery containing the Fedora Rawhide koji buildroot repositories.
|
||||
# get_rq() supports any release configuration builtin to fedrq
|
||||
# or configured on your local system.
|
||||
rq: RepoqueryBase = config.get_rq("rawhide", "buildroot")
|
||||
rq = config.get_rq("rawhide", "buildroot")
|
||||
|
||||
# Get all noarch packages that start with 'a' and depend on bash
|
||||
# The Repoquery.query() method returns a PackageQuery implementation.
|
||||
#
|
||||
# This gets all noarch packages that start with 'a' and depend on bash
|
||||
query = rq.query(
|
||||
name__glob="a*", arch="noarch", requires=rq.query(name="bash", arch="notsrc")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -178,8 +178,9 @@ class PackageCompat(Protocol): # pragma: no cover
|
|||
class PackageQueryCompat(Generic[_PackageT], metaclass=abc.ABCMeta): # pragma: no cover
|
||||
"""
|
||||
Common PackageQuery interface provided by hawkey.Query and other backends.
|
||||
When using to annotate function parameters and return value, use
|
||||
`PackageQueryAlias` instead of directly annotating with this type.
|
||||
When annotating function parameters and return values,
|
||||
use [`PackageQueryAlias`][fedrq.backends.base.PackageQueryAlias] instead of
|
||||
directly annotating with this type.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
|
@ -430,6 +431,9 @@ class RepoqueryBase(Generic[_PackageT], metaclass=abc.ABCMeta):
|
|||
"""
|
||||
Helpers to query a repository.
|
||||
Provides a unified repoquery interface for different backends.
|
||||
When annotating function parameters and return values,
|
||||
use [`RepoqueryAlias`][fedrq.backends.base.RepoqueryAlias] instead of
|
||||
directly annotating with this type.
|
||||
"""
|
||||
|
||||
def __init__(self, base) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue