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

Bump black from 22.12.0 to 24.3.0 #163

Merged
merged 7 commits into from
Apr 22, 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: 5 additions & 1 deletion nomad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Python library"""

import os
from typing import Optional

Expand Down Expand Up @@ -57,7 +58,10 @@ def __init__( # pylint: disable=too-many-arguments
- nomad.api.exceptions.URLNotFoundNomadException
- nomad.api.exceptions.URLNotAuthorizedNomadException
"""
cert = cert or (os.getenv("NOMAD_CLIENT_CERT", None), os.getenv("NOMAD_CLIENT_KEY", None))
cert = cert or (
os.getenv("NOMAD_CLIENT_CERT", None),
os.getenv("NOMAD_CLIENT_KEY", None),
)

self.host = host
self.secure = secure
Expand Down
1 change: 1 addition & 0 deletions nomad/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Python library"""

import nomad.api.exceptions
from nomad.api.acl import Acl
from nomad.api.agent import Agent
Expand Down
1 change: 1 addition & 0 deletions nomad/api/agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Agent: https://developer.hashicorp.com/nomad/api-docs/agent"""

from nomad.api.base import Requester


Expand Down
1 change: 1 addition & 0 deletions nomad/api/allocation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad allocation: https://developer.hashicorp.com/nomad/api-docs/allocations"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/allocations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad allocation: https://developer.hashicorp.com/nomad/api-docs/allocations"""

from typing import Optional

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Requester"""

from typing import Optional

import requests
Expand Down
15 changes: 8 additions & 7 deletions nomad/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __getattr__(self, item):


class ls(Requester):

"""
The /fs/ls endpoint is used to list files in an allocation directory.
This API endpoint is hosted by the Nomad client and requests have to be
Expand Down Expand Up @@ -67,7 +66,6 @@ def list_files(self, id_=None, path="/"):


class cat(Requester):

"""
The /fs/cat endpoint is used to read the contents of a file in an
allocation directory. This API endpoint is hosted by the Nomad
Expand Down Expand Up @@ -102,7 +100,6 @@ def read_file(self, id_=None, path="/"):


class read_at(Requester):

"""
This endpoint reads the contents of a file in an allocation directory at a particular offset and limit.

Expand Down Expand Up @@ -134,7 +131,6 @@ def read_file_offset(self, id_, offset, limit, path="/"):


class stream_file(Requester):

"""
This endpoint streams the contents of a file in an allocation directory.

Expand Down Expand Up @@ -166,7 +162,6 @@ def stream(self, id_, offset, origin, path="/"):


class stream_logs(Requester):

"""
This endpoint streams a task's stderr/stdout logs.

Expand Down Expand Up @@ -196,7 +191,14 @@ def stream(self, id_, task, type_, follow=False, offset=0, origin="start", plain
- nomad.api.exceptions.BaseNomadException
- nomad.api.exceptions.BadRequestNomadException
"""
params = {"task": task, "type": type_, "follow": follow, "offset": offset, "origin": origin, "plain": plain}
params = {
"task": task,
"type": type_,
"follow": follow,
"offset": offset,
"origin": origin,
"plain": plain,
}
return self.request(id_, params=params, method="get").text


Expand Down Expand Up @@ -304,7 +306,6 @@ def restart_allocation(self, id_):


class gc_allocation(Requester):

"""
This endpoint forces a garbage collection of a particular, stopped allocation on a node.

Expand Down
2 changes: 1 addition & 1 deletion nomad/api/deployment.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Nomad Deployment: https://developer.hashicorp.com/nomad/api-docs/deployments"""

import nomad.api.exceptions

from nomad.api.base import Requester


class Deployment(Requester):

"""
The /deployment endpoints are used to query for and interact with deployments.

Expand Down
1 change: 1 addition & 0 deletions nomad/api/deployments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Deployment: https://developer.hashicorp.com/nomad/api-docs/deployments"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/evaluation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Evaluation: https://developer.hashicorp.com/nomad/api-docs/evaluations"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/evaluations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Evaluations: https://developer.hashicorp.com/nomad/api-docs/evaluations"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Events: https://developer.hashicorp.com/nomad/api-docs/events"""

import json
import threading
import queue
Expand Down
1 change: 1 addition & 0 deletions nomad/api/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Internal library exceptions"""

import requests


Expand Down
6 changes: 5 additions & 1 deletion nomad/api/jobs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad job: https://developer.hashicorp.com/nomad/api-docs/jobs"""

from typing import Optional
import nomad.api.exceptions

Expand Down Expand Up @@ -119,5 +120,8 @@ def parse(self, hcl, canonicalize=False):
- nomad.api.exceptions.URLNotFoundNomadException
"""
return self.request(
"parse", json={"JobHCL": hcl, "Canonicalize": canonicalize}, method="post", allow_redirects=True
"parse",
json={"JobHCL": hcl, "Canonicalize": canonicalize},
method="post",
allow_redirects=True,
).json()
1 change: 1 addition & 0 deletions nomad/api/metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Metrics: https://developer.hashicorp.com/nomad/api-docs/metrics"""

from nomad.api.base import Requester


Expand Down
1 change: 1 addition & 0 deletions nomad/api/namespace.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad namespace: https://developer.hashicorp.com/nomad/api-docs/namespaces"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/namespaces.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad namespace: https://developer.hashicorp.com/nomad/api-docs/namespaces"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
14 changes: 12 additions & 2 deletions nomad/api/node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Node: https://developer.hashicorp.com/nomad/api-docs/nodes"""

from typing import Optional
import nomad.api.exceptions

Expand Down Expand Up @@ -125,7 +126,11 @@ def drain_node_with_spec(self, id_, drain_spec: Optional[dict], mark_eligible: O
payload = {}

if drain_spec and mark_eligible is not None:
payload = {"NodeID": id_, "DrainSpec": drain_spec, "MarkEligible": mark_eligible}
payload = {
"NodeID": id_,
"DrainSpec": drain_spec,
"MarkEligible": mark_eligible,
}
elif drain_spec and mark_eligible is None:
payload = {"NodeID": id_, "DrainSpec": drain_spec}
elif not drain_spec and mark_eligible is not None:
Expand All @@ -138,7 +143,12 @@ def drain_node_with_spec(self, id_, drain_spec: Optional[dict], mark_eligible: O

return self.request(id_, "drain", json=payload, method="post").json()

def eligible_node(self, id_: str, eligible: Optional[bool] = None, ineligible: Optional[bool] = None):
def eligible_node(
self,
id_: str,
eligible: Optional[bool] = None,
ineligible: Optional[bool] = None,
):
"""Toggle the eligibility of the node.

https://www.nomadproject.io/docs/http/node.html
Expand Down
1 change: 1 addition & 0 deletions nomad/api/nodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Node: https://developer.hashicorp.com/nomad/api-docs/nodes"""

from typing import Optional

import nomad.api.exceptions
Expand Down
1 change: 1 addition & 0 deletions nomad/api/operator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Operator: https://developer.hashicorp.com/nomad/api-docs/operator"""

from nomad.api.base import Requester


Expand Down
1 change: 1 addition & 0 deletions nomad/api/regions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad region: https://developer.hashicorp.com/nomad/api-docs/regions"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/scaling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Scalling API: https://developer.hashicorp.com/nomad/api-docs/scaling-policies"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
12 changes: 11 additions & 1 deletion nomad/api/search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Search API: https://developer.hashicorp.com/nomad/api-docs/search"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down Expand Up @@ -46,7 +47,16 @@ def search(self, prefix, context):
- nomad.api.exceptions.URLNotFoundNomadException
- nomad.api.exceptions.InvalidParameters
"""
accetaple_contexts = ("jobs", "evals", "allocs", "nodes", "deployment", "plugins", "volumes", "all")
accetaple_contexts = (
"jobs",
"evals",
"allocs",
"nodes",
"deployment",
"plugins",
"volumes",
"all",
)
if context not in accetaple_contexts:
raise nomad.api.exceptions.InvalidParameters(
"context is invalid " f"(expected values are {accetaple_contexts} but got {context})"
Expand Down
1 change: 1 addition & 0 deletions nomad/api/sentinel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Sentinel API: https://developer.hashicorp.com/nomad/api-docs/sentinel-policies"""

from nomad.api.base import Requester


Expand Down
1 change: 1 addition & 0 deletions nomad/api/status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Status API: https://developer.hashicorp.com/nomad/api-docs/status"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad System API: https://developer.hashicorp.com/nomad/api-docs/system"""

from nomad.api.base import Requester


Expand Down
2 changes: 1 addition & 1 deletion nomad/api/validate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Nomad Validate API: https://developer.hashicorp.com/nomad/api-docs/validate"""

from nomad.api.base import Requester


class Validate(Requester):

"""
The system endpoint is used to for system maintenance
and should not be necessary for most users.
Expand Down
1 change: 1 addition & 0 deletions nomad/api/variable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Valiables API: https://developer.hashicorp.com/nomad/api-docs/variables"""

import nomad.api.exceptions

from nomad.api.base import Requester
Expand Down
1 change: 1 addition & 0 deletions nomad/api/variables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nomad Valiables API: https://developer.hashicorp.com/nomad/api-docs/variables"""

from nomad.api.base import Requester


Expand Down
2 changes: 1 addition & 1 deletion requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pylint==2.15.10
black==22.12.0
black==24.4.0
Loading