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

Fix linting error on type checks #264

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
6 changes: 3 additions & 3 deletions pypuppetdb/QueryBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def __init__(self, operator):
self.operations = []

def add(self, query):
if type(query) == list:
if isinstance(query, list):
for i in query:
self.add(i)
elif type(query) == str:
elif isinstance(query, str):
self.operations.append(json.loads(query))
elif isinstance(query, (BinaryOperator, InOperator, BooleanOperator)):
self.operations.append(query.json_data())
Expand Down Expand Up @@ -652,7 +652,7 @@ class NullOperator(BinaryOperator):
"""

def __init__(self, field, value):
if type(value) != bool:
if not isinstance(value, bool):
raise APIError("NullOperator value must be boolean")

super().__init__("null?", field, value)
Expand Down
4 changes: 2 additions & 2 deletions pypuppetdb/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def nodes(self, unreported=2, with_status=False, with_event_numbers=True, **kwar
# If we happen to only get one node back it
# won't be inside a list so iterating over it
# goes boom. Therefor we wrap a list around it.
if type(nodes) == dict:
if isinstance(nodes, dict):
nodes = [
nodes,
]
Expand Down Expand Up @@ -239,7 +239,7 @@ def catalogs(self, **kwargs):

catalogs = self._query("catalogs", **kwargs)

if type(catalogs) == dict:
if isinstance(catalogs, dict):
catalogs = [
catalogs,
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api_pql.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_pql_casting(self, api):

nodes = list(api.pql(pql_query))

assert type(nodes[0]) == Node
assert isinstance(nodes[0], Node)
assert nodes[0].name == "greenserver.vm"

httpretty.disable()
Expand Down
Loading