Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hints, test building docs #210

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: docs

on: [push, pull_request]

jobs:
docs:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python setup.py develop
pip install -r docs/requirements.txt
- name: Build docs
run: |
cd docs
make html
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
max-parallel: 5
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
fail-fast: false

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
ALLSPHINXOPTS = -v -T -E -W --keep-going -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

Expand Down
7 changes: 6 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

# -- General configuration ----------------------------------------------------

extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx_rtd_theme"]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx_rtd_theme",
"sphinx_autodoc_typehints",
]

templates_path = ["_templates"]

Expand Down
3 changes: 3 additions & 0 deletions docs/developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ endpoints data.
.. autoclass:: pypuppetdb.types.Fact
.. autoclass:: pypuppetdb.types.Resource
.. autoclass:: pypuppetdb.types.Event
:members:
:special-members: __init__
.. autoclass:: pypuppetdb.types.Report
:members:
:special-members: __init__
.. autoclass:: pypuppetdb.types.Catalog
:members:
.. autoclass:: pypuppetdb.types.Edge
Expand Down
5 changes: 3 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sphinx
sphinx-rtd-theme
Sphinx>=4.0.0.b1,<5
sphinx-rtd-theme>=0.5.1,<1
sphinx-autodoc-typehints>=1.12.0,<2
7 changes: 4 additions & 3 deletions pypuppetdb/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
from datetime import datetime
from typing import Iterator

from pypuppetdb.QueryBuilder import (EqualsOperator)
from pypuppetdb.api.base import BaseAPI
Expand All @@ -18,7 +19,7 @@ class QueryAPI(BaseAPI):
"""

def nodes(self, unreported=2, with_status=False, with_event_numbers=True,
**kwargs):
**kwargs) -> Iterator[Node]:
r"""Query for nodes by either name or query. If both aren't
provided this will return a list of all nodes. This method
also (optionally) fetches the nodes status and (optionally)
Expand Down Expand Up @@ -211,7 +212,7 @@ def catalog(self, node):
catalogs = self.catalogs(path=node)
return next(catalog for catalog in catalogs)

def catalogs(self, **kwargs):
def catalogs(self, **kwargs) -> Iterator[Catalog]:
r"""Get the catalog information from the infrastructure based on path
and/or query results. It is strongly recommended to include query
and/or paging parameters for this endpoint to prevent large result
Expand All @@ -232,7 +233,7 @@ def catalogs(self, **kwargs):
for catalog in catalogs:
yield Catalog.create_from_dict(catalog)

def events(self, **kwargs):
def events(self, **kwargs) -> Iterator[Event]:
r"""A report is made up of events which can be queried either
individually or based on their associated report hash. It is strongly
recommended to include query and/or paging parameters for this
Expand Down
Loading