Skip to content

Commit 593baef

Browse files
authored
Fix crash on extra fields in response (#142)
* Fix crash on extra fields in public_net response * Run black for code formatting * Update CHANGELOG
1 parent da8ec1f commit 593baef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+4519
-3983
lines changed

.github/workflows/code_style.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ jobs:
1717
python -m pip install --upgrade pip
1818
pip install -r requirements/test.txt
1919
pip install tox tox-gh-actions
20-
- name: Test with tox
20+
sudo apt install build-essential
21+
- name: flake8 with tox
2122
run: tox -e flake8
23+
- name: black with tox
24+
run: tox -e black

.github/workflows/unit_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
python -m pip install --upgrade pip
2222
pip install -r requirements/test.txt
2323
pip install tox tox-gh-actions
24+
sudo apt install build-essential
2425
- name: Test with tox
2526
run: tox
2627
env:

.gitlab-ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ stages:
44
.tests_template: &tests_template
55
before_script:
66
- pip install tox
7+
- apk add build-base
78
stage: test
89
script:
910
tox
@@ -36,9 +37,8 @@ python310:
3637
script: tox -e py310
3738

3839
test-style:
39-
before_script:
40-
- pip install tox
40+
<<: *tests_template
4141
image: python:3.7-alpine
42-
script: tox -e flake8
43-
tags:
44-
- hc-bladerunner
42+
script:
43+
- tox -e flake8
44+
- tox -e black

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
History
33
=======
44

5+
v1.14.1 (2021-08-10)
6+
---------------------
7+
* Bugfix: Fix crash on extra fields in public_net response
8+
* Improvement: Format code with black
9+
510
v1.14.0 (2021-08-03)
611
---------------------
712
* Feature: Add support for Firewall rule descriptions

docs/conf.py

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import os
2222
import sys
2323

24-
sys.path.insert(0, os.path.abspath('..'))
24+
sys.path.insert(0, os.path.abspath(".."))
2525
from hcloud.__version__ import VERSION # noqa
2626

2727
# -- General configuration ---------------------------------------------
@@ -32,10 +32,10 @@
3232

3333
# Add any Sphinx extension module names here, as strings. They can be
3434
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
35-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
35+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
3636

3737
# Add any paths that contain templates here, relative to this directory.
38-
templates_path = ['_templates']
38+
templates_path = ["_templates"]
3939

4040
# The suffix(es) of source filenames.
4141
# You can specify multiple suffix as a list of string:
@@ -44,10 +44,10 @@
4444
# source_suffix = '.rst'
4545

4646
# The master toctree document.
47-
master_doc = 'index'
47+
master_doc = "index"
4848

4949
# General information about the project.
50-
project = u'Hetzner Cloud Python'
50+
project = u"Hetzner Cloud Python"
5151
copyright = u"2019, Hetzner Cloud GmbH"
5252
author = u"Hetzner Cloud GmbH"
5353

@@ -70,10 +70,10 @@
7070
# List of patterns, relative to source directory, that match files and
7171
# directories to ignore when looking for source files.
7272
# This patterns also effect to html_static_path and html_extra_path
73-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
73+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
7474

7575
# The name of the Pygments (syntax highlighting) style to use.
76-
pygments_style = 'sphinx'
76+
pygments_style = "sphinx"
7777

7878
# If true, `todo` and `todoList` produce output, else they produce nothing.
7979
todo_include_todos = False
@@ -87,41 +87,38 @@
8787
# The theme to use for HTML and HTML Help pages. See the documentation for
8888
# a list of builtin themes.
8989
#
90-
html_theme = 'sphinx_rtd_theme'
91-
html_logo = '_static/logo-hetzner-online.svg'
90+
html_theme = "sphinx_rtd_theme"
91+
html_logo = "_static/logo-hetzner-online.svg"
9292
# Theme options are theme-specific and customize the look and feel of a
9393
# theme further. For a list of options available for each theme, see the
9494
# documentation.
9595
#
9696
html_theme_options = {
97-
'logo_only': True,
97+
"logo_only": True,
9898
}
9999

100100
# Add any paths that contain custom static files (such as style sheets) here,
101101
# relative to this directory. They are copied after the builtin static files,
102102
# so a file named "default.css" will overwrite the builtin "default.css".
103-
html_static_path = ['_static']
103+
html_static_path = ["_static"]
104104

105105
# -- Options for HTMLHelp output ---------------------------------------
106106

107107
# Output file base name for HTML help builder.
108-
htmlhelp_basename = 'hclouddoc'
108+
htmlhelp_basename = "hclouddoc"
109109

110110
# -- Options for LaTeX output ------------------------------------------
111111

112112
latex_elements = {
113113
# The paper size ('letterpaper' or 'a4paper').
114114
#
115115
# 'papersize': 'letterpaper',
116-
117116
# The font size ('10pt', '11pt' or '12pt').
118117
#
119118
# 'pointsize': '10pt',
120-
121119
# Additional stuff for the LaTeX preamble.
122120
#
123121
# 'preamble': '',
124-
125122
# Latex figure (float) alignment
126123
#
127124
# 'figure_align': 'htbp',
@@ -131,32 +128,34 @@
131128
# (source start file, target name, title, author, documentclass
132129
# [howto, manual, or own class]).
133130
latex_documents = [
134-
(master_doc, 'hcloud.tex',
135-
u'Hetzner Cloud Python Documentation',
136-
u'Hetzner Cloud GmbH', 'manual'),
131+
(
132+
master_doc,
133+
"hcloud.tex",
134+
u"Hetzner Cloud Python Documentation",
135+
u"Hetzner Cloud GmbH",
136+
"manual",
137+
),
137138
]
138139

139140
# -- Options for manual page output ------------------------------------
140141

141142
# One entry per manual page. List of tuples
142143
# (source start file, name, description, authors, manual section).
143-
man_pages = [
144-
(master_doc,
145-
u'Hetzner Cloud Python Documentation',
146-
[author], 1)
147-
]
144+
man_pages = [(master_doc, u"Hetzner Cloud Python Documentation", [author], 1)]
148145

149146
# -- Options for Texinfo output ----------------------------------------
150147

151148
# Grouping the document tree into Texinfo files. List of tuples
152149
# (source start file, target name, title, author,
153150
# dir menu entry, description, category)
154151
texinfo_documents = [
155-
(master_doc,
156-
u'Hetzner Cloud Python Documentation',
157-
author,
158-
'HCloud-python is a library for the Hetzner Cloud API.',
159-
'Miscellaneous'),
152+
(
153+
master_doc,
154+
u"Hetzner Cloud Python Documentation",
155+
author,
156+
"HCloud-python is a library for the Hetzner Cloud API.",
157+
"Miscellaneous",
158+
),
160159
]
161160

162-
source_suffix = ['.rst']
161+
source_suffix = [".rst"]

examples/create_server.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
from hcloud.images.domain import Image
33
from hcloud.server_types.domain import ServerType
44

5-
client = Client(token="{YOUR_API_TOKEN}") # Please paste your API token here between the quotes
6-
response = client.servers.create(name="my-server", server_type=ServerType("cx11"), image=Image(name="ubuntu-20.04"))
5+
client = Client(
6+
token="{YOUR_API_TOKEN}"
7+
) # Please paste your API token here between the quotes
8+
response = client.servers.create(
9+
name="my-server", server_type=ServerType("cx11"), image=Image(name="ubuntu-20.04")
10+
)
711
server = response.server
812
print(server)
913
print("Root Password" + response.root_password)

examples/list_servers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from hcloud import Client
22

3-
client = Client(token="{YOUR_API_TOKEN}") # Please paste your API token here between the quotes
3+
client = Client(
4+
token="{YOUR_API_TOKEN}"
5+
) # Please paste your API token here between the quotes
46
servers = client.servers.get_all()
57
print(servers)

examples/usage_oop.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@
88
# Create 2 servers
99
# Create 2 servers
1010
response1 = client.servers.create(
11-
"Server1",
12-
server_type=ServerType(name="cx11"),
13-
image=Image(id=4711)
11+
"Server1", server_type=ServerType(name="cx11"), image=Image(id=4711)
1412
)
1513

1614
response2 = client.servers.create(
17-
"Server2",
18-
server_type=ServerType(name="cx11"),
19-
image=Image(id=4711)
15+
"Server2", server_type=ServerType(name="cx11"), image=Image(id=4711)
2016
)
2117
# Get all servers
2218
server1 = response1.server
@@ -28,16 +24,8 @@
2824
assert servers[1].id == server2.id
2925
# Create 2 volumes
3026

31-
response1 = client.volumes.create(
32-
size=15,
33-
name="Volume1",
34-
location=server1.location
35-
)
36-
response2 = client.volumes.create(
37-
size=10,
38-
name="Volume2",
39-
location=server2.location
40-
)
27+
response1 = client.volumes.create(size=15, name="Volume1", location=server1.location)
28+
response2 = client.volumes.create(size=10, name="Volume2", location=server2.location)
4129

4230
volume1 = response1.volume
4331
volume2 = response2.volume

examples/usage_procedurale.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99

1010
# Create 2 servers
1111
response1 = client.servers.create(
12-
name="Server1",
13-
server_type=ServerType(name="cx11"),
14-
image=Image(id=4711)
12+
name="Server1", server_type=ServerType(name="cx11"), image=Image(id=4711)
1513
)
1614

1715
response2 = client.servers.create(
18-
"Server2",
19-
server_type=ServerType(name="cx11"),
20-
image=Image(id=4711)
16+
"Server2", server_type=ServerType(name="cx11"), image=Image(id=4711)
2117
)
2218

2319
server1 = response1.server
@@ -32,16 +28,8 @@
3228

3329
# Create 2 volumes
3430

35-
response1 = client.volumes.create(
36-
size=15,
37-
name="Volume1",
38-
location=server1.location
39-
)
40-
response2 = client.volumes.create(
41-
size=10,
42-
name="Volume2",
43-
location=server2.location
44-
)
31+
response1 = client.volumes.create(size=15, name="Volume1", location=server1.location)
32+
response2 = client.volumes.create(size=10, name="Volume2", location=server2.location)
4533

4634
volume1 = response1.volume
4735
volume2 = response2.volume
@@ -61,11 +49,7 @@
6149
# Create one more volume and attach it to server with id=33
6250

6351
server33 = Server(id=33)
64-
response = client.volumes.create(
65-
size=33,
66-
name="Volume33",
67-
server=server33
68-
)
52+
response = client.volumes.create(size=33, name="Volume33", server=server33)
6953

7054
print(response.action.status)
7155

@@ -74,5 +58,5 @@
7458
"Server3",
7559
server_type=ServerType(name="cx11"),
7660
image=Image(id=4711),
77-
volumes = [Volume(id=221), Volume(id=222)]
61+
volumes=[Volume(id=221), Volume(id=222)],
7862
)

hcloud/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '1.13.0'
1+
VERSION = "1.13.0"

hcloud/actions/client.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def wait_until_finished(self, max_retries=100):
2929

3030

3131
class ActionsClient(ClientEntityBase):
32-
results_list_attribute_name = 'actions'
32+
results_list_attribute_name = "actions"
3333

3434
def get_by_id(self, id):
3535
# type: (int) -> BoundAction
@@ -39,15 +39,18 @@ def get_by_id(self, id):
3939
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
4040
"""
4141

42-
response = self._client.request(url="/actions/{action_id}".format(action_id=id), method="GET")
43-
return BoundAction(self, response['action'])
44-
45-
def get_list(self,
46-
status=None, # type: Optional[List[str]]
47-
sort=None, # type: Optional[List[str]]
48-
page=None, # type: Optional[int]
49-
per_page=None, # type: Optional[int]
50-
):
42+
response = self._client.request(
43+
url="/actions/{action_id}".format(action_id=id), method="GET"
44+
)
45+
return BoundAction(self, response["action"])
46+
47+
def get_list(
48+
self,
49+
status=None, # type: Optional[List[str]]
50+
sort=None, # type: Optional[List[str]]
51+
page=None, # type: Optional[int]
52+
per_page=None, # type: Optional[int]
53+
):
5154
# type: (...) -> PageResults[List[BoundAction]]
5255
"""Get a list of actions from this account
5356
@@ -72,7 +75,9 @@ def get_list(self,
7275
params["per_page"] = per_page
7376

7477
response = self._client.request(url="/actions", method="GET", params=params)
75-
actions = [BoundAction(self, action_data) for action_data in response['actions']]
78+
actions = [
79+
BoundAction(self, action_data) for action_data in response["actions"]
80+
]
7681
return self._add_meta_to_result(actions, response)
7782

7883
def get_all(self, status=None, sort=None):

0 commit comments

Comments
 (0)