Skip to content

Commit c77dc50

Browse files
authored
Merge pull request #213 from gdubicki/add_python_3.10
Add Python 3.10 support
2 parents 1c6a26e + 3f1d255 commit c77dc50

21 files changed

+87
-91
lines changed

.coveragerc

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
[report]
22
exclude_lines =
33
pragma: notest
4+
5+
[run]
6+
source =
7+
pypuppetdb
8+
9+
omit =
10+
# don't check the test themselves, obviously
11+
tests/*
12+
13+
# no point in checking this
14+
setup.py

.github/workflows/publish-to-pypi.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v2
15-
- name: Set up Python 3.8
15+
- name: Set up Python 3.9
1616
uses: actions/setup-python@v2
1717
with:
18-
python-version: 3.8
18+
python-version: 3.9
1919
- name: Install dependencies
2020
run: |
2121
pip install wheel

.github/workflows/security.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- name: Set up Python 3.8
12+
- name: Set up Python 3.9
1313
uses: actions/setup-python@v2
1414
with:
15-
python-version: 3.8
15+
python-version: 3.9
1616
- name: Install dependencies
1717
run: |
1818
pip install bandit

.github/workflows/tests.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
max-parallel: 5
1212
matrix:
13-
python-version: [3.6, 3.7, 3.8, 3.9]
13+
python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev]
1414

1515
steps:
1616
- uses: actions/checkout@v2
@@ -20,12 +20,13 @@ jobs:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install dependencies
2222
run: |
23+
pip install --upgrade wheel setuptools
2324
pip install -r requirements-test.txt
25+
mypy --install-types --non-interactive pypuppetdb/ tests/
2426
- name: Test
2527
run: |
26-
pytest --pep8 --strict-markers --mypy pypuppetdb tests
27-
- name: Run coveralls
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30-
run: |
31-
coveralls --service=github
28+
pytest --cov=. --cov-report=xml --flake8 --strict-markers --mypy pypuppetdb tests
29+
- name: Upload coverage to Codecov
30+
uses: codecov/codecov-action@v2
31+
with:
32+
fail_ci_if_error: true

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pip-log.txt
2727

2828
# Unit test / coverage reports
2929
.coverage
30+
coverage.xml
3031
.tox
3132
nosetests.xml
3233
htmlcov
@@ -48,3 +49,6 @@ docs/_build
4849

4950
# OS X
5051
.DS_*
52+
53+
# private test data
54+
private/

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sphinx:
66
fail_on_warning: true
77

88
python:
9-
version: 3.8
9+
version: 3.9
1010
install:
1111
- requirements: docs/requirements.txt
1212
- method: setuptools

CONTRIBUTING.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Pope](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
2828
# Create a Python 3 virtualenv and activate it
2929
virtualenv -p python3 .venv
3030
. .venv/bin/activate
31+
# Get the up to date base packages
32+
pip install --upgrade wheel setuptools
3133
# Install the module in a development mode
3234
python setup.py develop
3335
# Install test dependencies
@@ -44,7 +46,8 @@ do this to run the tests:
4446

4547
```bash
4648
# Unit tests, with PEP8 and mypy (static typing) checks
47-
pytest --pep8 --strict-markers --mypy pypuppetdb tests
49+
mypy --install-types --non-interactive pypuppetdb/ tests/
50+
pytest --flake8 --strict-markers --mypy pypuppetdb tests
4851
# Security linter
4952
bandit -r pypuppetdb
5053
```

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pypuppetdb)](https://pypi.org/project/pypuppetdb/)
55
[![PyPi Downloads](https://img.shields.io/pypi/dm/pypuppetdb)](https://pypi.org/project/pypuppetdb/)
66
![Tests Status](https://github.com/voxpupuli/pypuppetdb/workflows/tests%20(unit)/badge.svg)
7-
[![Coverage Status](https://img.shields.io/coveralls/voxpupuli/pypuppetdb.svg)](https://coveralls.io/r/voxpupuli/pypuppetdb)
7+
[![codecov](https://codecov.io/gh/voxpupuli/pypuppetdb/branch/master/graph/badge.svg?token=mOOj805A15)](https://codecov.io/gh/voxpupuli/pypuppetdb)
88
[![Documentation Status](https://readthedocs.org/projects/pypuppetdb/badge/?version=latest)](https://pypuppetdb.readthedocs.io/en/latest/?badge=latest)
99
[![By Voxpupuli](https://img.shields.io/badge/by-Vox%20Pupuli%20%F0%9F%A6%8A-ef902f.svg)](https://voxpupuli.org)
1010

@@ -16,7 +16,7 @@ PuppetDB.
1616

1717
* PuppetDB 3.0 or newer
1818
* (For support of older PuppetDB versions please check versions < 0.2.0)
19-
* Python 3.6 / 3.7 / 3.8 / 3.9
19+
* Python 3.6 / 3.7 / 3.8 / 3.9 / 3.10
2020

2121
## Installation
2222

pypuppetdb/QueryBuilder.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ def add_array(self, values):
288288
if self.query is not None:
289289
raise APIError("Only one array is supported by the InOperator")
290290
elif isinstance(values, list):
291-
def depth(l):
292-
return (isinstance(l, list) and len(l) != 0) \
293-
and max(map(depth, l)) + 1
291+
def depth(a_list):
292+
return (isinstance(a_list, list) and len(a_list) != 0) \
293+
and max(map(depth, a_list)) + 1
294294

295295
if depth(values) == 1:
296296
self.query = True
@@ -358,8 +358,8 @@ def add_query(self, query):
358358
"Operator Objects")
359359

360360
def add_order_by(self, fields):
361-
def depth(l):
362-
return isinstance(l, list) and max(map(depth, l)) + 1
361+
def depth(a_list):
362+
return isinstance(a_list, list) and max(map(depth, a_list)) + 1
363363

364364
fields_depth = depth(fields)
365365

pypuppetdb/api/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def _query(self, endpoint=None, path=None, query=None,
325325
:rtype: :obj:`dict` or :obj:`list`
326326
"""
327327

328-
log.debug(f"_query called with ",
328+
log.debug("_query called with ",
329329
# comma-separated list of method arguments with their values
330330
", ".join([f"{arg}: {locals().get(arg, 'None')}"
331331
for arg in locals().keys() if arg != 'self'])

pypuppetdb/api/pql.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pypuppetdb.QueryBuilder import (EqualsOperator)
1010
from pypuppetdb.api.base import BaseAPI
1111
from pypuppetdb.errors import (APIError)
12-
from pypuppetdb.types import (Catalog, Node, Report)
12+
from pypuppetdb.types import (Node, Report)
1313

1414
log = logging.getLogger(__name__)
1515

@@ -151,5 +151,5 @@ def _get_type_from_query(pql):
151151
f" but it is not supported by this library yet.")
152152
return None
153153
else:
154-
log.debug(f"No match!")
154+
log.debug("No match!")
155155
return None

pypuppetdb/api/query.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
from datetime import datetime
66

7-
import pypuppetdb
87
from pypuppetdb.QueryBuilder import (EqualsOperator)
98
from pypuppetdb.api.base import BaseAPI
109
from pypuppetdb.types import (Catalog, Edge, Event, Fact, Inventory,
@@ -39,7 +38,7 @@ def nodes(self, unreported=2, with_status=False, with_event_numbers=True,
3938
This provides performance benefits as potentially
4039
slow event-counts query is omitted completely.
4140
:type with_event_numbers: :bool:
42-
:param \*\*kwargs: The rest of the keyword arguments are passed
41+
:param **kwargs: The rest of the keyword arguments are passed
4342
to the _query function
4443
4544
:returns: A generator yieling Nodes.
@@ -81,7 +80,7 @@ def node(self, name):
8180
def edges(self, **kwargs):
8281
"""Get the known catalog edges, formed between two resources.
8382
84-
:param \*\*kwargs: The rest of the keyword arguments are passed
83+
:param **kwargs: The rest of the keyword arguments are passed
8584
to the _query function.
8685
8786
:returns: A generating yielding Edges.
@@ -95,7 +94,7 @@ def edges(self, **kwargs):
9594
def environments(self, **kwargs):
9695
"""Get all known environments from Puppetdb.
9796
98-
:param \*\*kwargs: The rest of the keyword arguments are passed
97+
:param **kwargs: The rest of the keyword arguments are passed
9998
to the _query function.
10099
101100
:returns: A list of dictionaries containing the results.
@@ -112,7 +111,7 @@ def facts(self, name=None, value=None, **kwargs):
112111
match this value. Use of this parameter requires the `name`\
113112
parameter be set.
114113
:type value: :obj:`string`
115-
:param \*\*kwargs: The rest of the keyword arguments are passed
114+
:param **kwargs: The rest of the keyword arguments are passed
116115
to the _query function
117116
118117
:returns: A generator yielding Facts.
@@ -132,7 +131,7 @@ def facts(self, name=None, value=None, **kwargs):
132131
def factsets(self, **kwargs):
133132
"""Returns a set of all facts or for a single certname.
134133
135-
:param \*\*kwargs: The rest of the keyword arguments are passed
134+
:param **kwargs: The rest of the keyword arguments are passed
136135
to the _query function.
137136
138137
:returns: A list of dictionaries containg the results.
@@ -145,7 +144,7 @@ def fact_contents(self, **kwargs):
145144
to descend into structured facts and retreive the values associated
146145
with fact paths.
147146
148-
:param \*\*kwargs: The rest of the keyword arguments are passed
147+
:param **kwargs: The rest of the keyword arguments are passed
149148
to the _query function.
150149
151150
:returns: A list of dictionaries containg the results.
@@ -159,7 +158,7 @@ def fact_paths(self, **kwargs):
159158
facts and may be used for building GUI autocompletions or other
160159
applications that require a basic top-level view of fact paths.
161160
162-
:param \*\*kwargs: The rest of the keyword arguments are passed
161+
:param **kwargs: The rest of the keyword arguments are passed
163162
to the _query function.
164163
165164
:returns: A list of dictionaries containg the results.
@@ -179,7 +178,7 @@ def resources(self, type_=None, title=None, **kwargs):
179178
'namevar' in the Puppet Manifests. This parameter requires the\
180179
`type_` parameter be set.
181180
:type title: :obj:`string`
182-
:param \*\*kwargs: The rest of the keyword arguments are passed
181+
:param **kwargs: The rest of the keyword arguments are passed
183182
to the _query function
184183
185184
:returns: A generator yielding Resources
@@ -218,7 +217,7 @@ def catalogs(self, **kwargs):
218217
and/or paging parameters for this endpoint to prevent large result
219218
sets or PuppetDB performance bottlenecks.
220219
221-
:param \*\*kwargs: The rest of the keyword arguments are passed
220+
:param **kwargs: The rest of the keyword arguments are passed
222221
to the _query function.
223222
224223
:returns: A generator yielding Catalogs
@@ -240,7 +239,7 @@ def events(self, **kwargs):
240239
endpoint to prevent large result sets or PuppetDB performance
241240
bottlenecks.
242241
243-
:param \*\*kwargs: The rest of the keyword arguments are passed
242+
:param **kwargs: The rest of the keyword arguments are passed
244243
to the _query function
245244
246245
:returns: A generator yielding Events
@@ -268,7 +267,7 @@ def event_counts(self, summarize_by, **kwargs):
268267
`<`, `>=`, and `<=`. Supported fields are
269268
`failures`, `successes`, `noops`, and `skips`.
270269
:type count_filter: :obj:`string`
271-
:param \*\*kwargs: The rest of the keyword arguments are passed
270+
:param **kwargs: The rest of the keyword arguments are passed
272271
to the _query function.
273272
274273
:returns: A list of dictionaries containing the results.
@@ -319,7 +318,7 @@ def reports(self, **kwargs):
319318
prevent large result sets and potential PuppetDB performance
320319
bottlenecks.
321320
322-
:param \*\*kwargs: The rest of the keyword arguments are passed
321+
:param **kwargs: The rest of the keyword arguments are passed
323322
to the _query function
324323
325324
:returns: A generating yielding Reports
@@ -334,7 +333,7 @@ def inventory(self, **kwargs):
334333
for structured facts instead of using the facts, fact-contents and
335334
factsets endpoints for many fact-related queries.
336335
337-
:param \*\*kwargs: The rest of the keyword arguments are passed
336+
:param **kwargs: The rest of the keyword arguments are passed
338337
to the _query function.
339338
340339
:returns: A generator yielding Inventory

0 commit comments

Comments
 (0)