Skip to content

Commit 048bd49

Browse files
committed
Initial integration for black
This contains the necessary changes to start using black with the codebase. Right now, only the files under the examples and docs folders and hazelcast/__init__.py is reformatted and checked. Since black only works on py3.6+, we will only be using it in python3 pr builder. Also, added a missing exclude package(`docs.*`) to setup.py and separated test and dev dependencies.
1 parent 3390689 commit 048bd49

Some content is hidden

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

45 files changed

+278
-243
lines changed

README.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,14 @@ Development
198198
<https://github.com/hazelcast/hazelcast-python-client.git>`__.
199199
2. Run ``python setup.py install`` to install the Python client.
200200

201-
If you are planning to contribute, please make sure that it fits the
202-
guidelines described in
203-
`PEP8 <https://www.python.org/dev/peps/pep-0008/>`__.
201+
If you are planning to contribute:
202+
203+
1. Run ``pip install -r requirements-dev.txt`` to install development
204+
dependencies.
205+
2. Use `black <https://pypi.org/project/black/>`__ to reformat the code
206+
by running the ``black .`` command.
207+
3. Make sure that tests are passing by following the steps described
208+
in the next section.
204209

205210
Testing
206211
^^^^^^^

docs/conf.py

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# If extensions (or modules to document with autodoc) are in another directory,
1919
# add these directories to sys.path here. If the directory is relative to the
2020
# documentation root, use os.path.abspath to make it absolute, like shown here.
21-
sys.path.insert(0, os.path.abspath('..'))
21+
sys.path.insert(0, os.path.abspath(".."))
2222

2323
# -- General configuration ------------------------------------------------
2424

@@ -29,17 +29,17 @@
2929
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3030
# ones.
3131
extensions = [
32-
'sphinx.ext.autodoc',
33-
'sphinx.ext.autosummary',
34-
'sphinx.ext.napoleon',
35-
'sphinx.ext.viewcode',
36-
'sphinx.ext.autosectionlabel',
32+
"sphinx.ext.autodoc",
33+
"sphinx.ext.autosummary",
34+
"sphinx.ext.napoleon",
35+
"sphinx.ext.viewcode",
36+
"sphinx.ext.autosectionlabel",
3737
]
3838

3939
autodoc_default_options = {
40-
'members': None,
41-
'undoc-members': None,
42-
'show-inheritance': None,
40+
"members": None,
41+
"undoc-members": None,
42+
"show-inheritance": None,
4343
}
4444

4545
# Autosummary on
@@ -49,35 +49,35 @@
4949
autosectionlabel_prefix_document = True
5050

5151
# Add any paths that contain templates here, relative to this directory.
52-
templates_path = ['_templates']
52+
templates_path = ["_templates"]
5353

5454
# The suffix(es) of source filenames.
5555
# You can specify multiple suffix as a list of string:
5656
# source_suffix = ['.rst', '.md']
57-
source_suffix = '.rst'
57+
source_suffix = ".rst"
5858

5959
# The encoding of source files.
6060
# source_encoding = 'utf-8-sig'
6161

6262
# The master toctree document.
63-
master_doc = 'index'
63+
master_doc = "index"
6464

6565
# General information about the project.
66-
project = u'Hazelcast Python Client'
67-
copyright = u'2020, Hazelcast Inc.'
68-
author = u'Hazelcast Inc. Developers'
66+
project = u"Hazelcast Python Client"
67+
copyright = u"2020, Hazelcast Inc."
68+
author = u"Hazelcast Inc. Developers"
6969

7070
# The version info for the project you're documenting, acts as replacement for
7171
# |version| and |release|, also used in various other places throughout the
7272
# built documents.
7373
#
7474
# The short X.Y version.
75-
version = '4.0.0'
75+
version = "4.0.0"
7676
# The full version, including alpha/beta/rc tags.
77-
release = '4.0.0b1'
77+
release = "4.0.0b1"
7878

79-
autodoc_member_order = 'bysource'
80-
autoclass_content = 'both'
79+
autodoc_member_order = "bysource"
80+
autoclass_content = "both"
8181

8282
# The language for content autogenerated by Sphinx. Refer to documentation
8383
# for a list of supported languages.
@@ -95,7 +95,7 @@
9595
# List of patterns, relative to source directory, that match files and
9696
# directories to ignore when looking for source files.
9797
# This patterns also effect to html_static_path and html_extra_path
98-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
98+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
9999

100100
# The reST default role (used for this markup: `text`) to use for all
101101
# documents.
@@ -113,7 +113,7 @@
113113
# show_authors = False
114114

115115
# The name of the Pygments (syntax highlighting) style to use.
116-
pygments_style = 'sphinx'
116+
pygments_style = "sphinx"
117117

118118
# A list of ignored prefixes for module index sorting.
119119
# modindex_common_prefix = []
@@ -128,7 +128,7 @@
128128

129129
# The theme to use for HTML and HTML Help pages. See the documentation for
130130
# a list of builtin themes.
131-
html_theme = 'default'
131+
html_theme = "default"
132132

133133
# Theme options are theme-specific and customize the look and feel of a theme
134134
# further. For a list of options available for each theme, see the
@@ -222,20 +222,17 @@
222222
# html_search_scorer = 'scorer.js'
223223

224224
# Output file base name for HTML help builder.
225-
htmlhelp_basename = 'hazelcast-python-clientdoc'
225+
htmlhelp_basename = "hazelcast-python-clientdoc"
226226

227227
# -- Options for LaTeX output ---------------------------------------------
228228

229229
latex_elements = {
230230
# The paper size ('letterpaper' or 'a4paper').
231231
# 'papersize': 'letterpaper',
232-
233232
# The font size ('10pt', '11pt' or '12pt').
234233
# 'pointsize': '10pt',
235-
236234
# Additional stuff for the LaTeX preamble.
237235
# 'preamble': '',
238-
239236
# Latex figure (float) alignment
240237
# 'figure_align': 'htbp',
241238
}
@@ -244,8 +241,13 @@
244241
# (source start file, target name, title,
245242
# author, documentclass [howto, manual, or own class]).
246243
latex_documents = [
247-
(master_doc, 'hazelcast-python-client.tex', u'Hazelcast Python Client Documentation',
248-
author, 'manual'),
244+
(
245+
master_doc,
246+
"hazelcast-python-client.tex",
247+
u"Hazelcast Python Client Documentation",
248+
author,
249+
"manual",
250+
),
249251
]
250252

251253
# The name of an image file (relative to this directory) to place at the top of
@@ -274,8 +276,7 @@
274276
# One entry per manual page. List of tuples
275277
# (source start file, name, description, authors, manual section).
276278
man_pages = [
277-
(master_doc, 'hazelcast-python-client', u'Hazelcast Python Client Documentation',
278-
[author], 1)
279+
(master_doc, "hazelcast-python-client", u"Hazelcast Python Client Documentation", [author], 1)
279280
]
280281

281282
# If true, show URL addresses after external links.
@@ -288,9 +289,15 @@
288289
# (source start file, target name, title, author,
289290
# dir menu entry, description, category)
290291
texinfo_documents = [
291-
(master_doc, 'hazelcast-python-client', u'Hazelcast Python Client Documentation',
292-
author, 'hazelcast-python-client', 'One line description of project.',
293-
'Miscellaneous'),
292+
(
293+
master_doc,
294+
"hazelcast-python-client",
295+
u"Hazelcast Python Client Documentation",
296+
author,
297+
"hazelcast-python-client",
298+
"One line description of project.",
299+
"Miscellaneous",
300+
),
294301
]
295302

296303
# Documents to append as an appendix to all manuals.
@@ -305,12 +312,10 @@
305312
# If true, do not generate a @detailmenu in the "Top" node's menu.
306313
# texinfo_no_detailmenu = False
307314

308-
on_rtd = os.environ.get('READTHEDOCS') == 'True'
315+
on_rtd = os.environ.get("READTHEDOCS") == "True"
309316

310317
if not on_rtd:
311318
# If we are building locally, import the RTD theme
312319
# and use it
313-
314-
import sphinx_rtd_theme
315-
extensions.append('sphinx_rtd_theme')
316-
html_theme = 'sphinx_rtd_theme'
320+
extensions.append("sphinx_rtd_theme")
321+
html_theme = "sphinx_rtd_theme"

docs/development_and_testing.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ its source:
1515
(https://github.com/hazelcast/hazelcast-python-client.git).
1616
2. Run ``python setup.py install`` to install the Python client.
1717

18-
If you are planning to contribute, please make sure that it fits the
19-
guidelines described in
20-
`PEP8 <https://www.python.org/dev/peps/pep-0008/>`__.
18+
If you are planning to contribute:
19+
20+
1. Run ``pip install -r requirements-dev.txt`` to install development
21+
dependencies.
22+
2. Use `black <https://pypi.org/project/black/>`__ to reformat the code
23+
by running the ``black .`` command.
24+
3. Make sure that tests are passing by following the steps described
25+
in the :ref:`development_and_testing:testing` section.
2126

2227
Testing
2328
-------

examples/cloud-discovery/hazelcast_cloud_discovery_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ssl_cafile="/path/to/ca.pem",
1212
ssl_certfile="/path/to/cert.pem",
1313
ssl_keyfile="/path/to/key.pem",
14-
ssl_password="YOUR_KEY_STORE_PASSWORD"
14+
ssl_password="YOUR_KEY_STORE_PASSWORD",
1515
)
1616

1717
my_map = client.get_map("map-on-the-cloud").blocking()

examples/flake-id-generator/flake_id_generator_example.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import hazelcast
22

3-
client = hazelcast.HazelcastClient(flake_id_generators={
4-
"id-generator": {
5-
"prefetch_count": 50,
6-
"prefetch_validity": 30,
3+
client = hazelcast.HazelcastClient(
4+
flake_id_generators={
5+
"id-generator": {
6+
"prefetch_count": 50,
7+
"prefetch_validity": 30,
8+
}
79
}
8-
})
10+
)
911

1012
generator = client.get_flake_id_generator("id-generator").blocking()
1113

examples/hazelcast-json-value/hazelcast_json_value_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
client = hazelcast.HazelcastClient()
77
employees_map = client.get_map("employees").blocking()
88

9-
alice = "{\"name\": \"Alice\", \"age\": 35}"
10-
andy = "{\"name\": \"Andy\", \"age\": 22}"
9+
alice = '{"name": "Alice", "age": 35}'
10+
andy = '{"name": "Andy", "age": 22}'
1111
bob = {"name": "Bob", "age": 37}
1212

1313
# HazelcastJsonValue can be constructed from JSON strings

examples/learning-basics/2-create_a_map.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import hazelcast
22

33
# Connect
4-
client = hazelcast.HazelcastClient(
5-
cluster_members=[
6-
"127.0.0.1:5701"
7-
]
8-
)
4+
client = hazelcast.HazelcastClient(cluster_members=["127.0.0.1:5701"])
95

106
# Get a map that is stored on the server side. We can access it from the client
117
greetings_map = client.get_map("greetings-map").blocking()

examples/learning-basics/3-read_from_a_map.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import hazelcast
22

33
# Connect
4-
client = hazelcast.HazelcastClient(
5-
cluster_members=[
6-
"127.0.0.1:5701"
7-
]
8-
)
4+
client = hazelcast.HazelcastClient(cluster_members=["127.0.0.1:5701"])
95

106
# We can access maps on the server from the client. Let's access the greetings map that we created already
117
greetings_map = client.get_map("greetings-map").blocking()

examples/map/map_listener_example.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ def entry_removed(event):
1212

1313

1414
def entry_updated(event):
15-
print("Entry updated with key: %s, old value: %s, new value: %s" % (event.key, event.old_value, event.value))
15+
print(
16+
"Entry updated with key: %s, old value: %s, new value: %s"
17+
% (event.key, event.old_value, event.value)
18+
)
1619

1720

1821
client = hazelcast.HazelcastClient()
1922

2023
my_map = client.get_map("listener-map").blocking()
2124

22-
my_map.add_entry_listener(True, added_func=entry_added, removed_func=entry_removed, updated_func=entry_updated)
25+
my_map.add_entry_listener(
26+
True, added_func=entry_added, removed_func=entry_removed, updated_func=entry_updated
27+
)
2328

2429
my_map.put("key", "value")
2530
my_map.put("key", "new value")

examples/map/map_paging_predicate_example.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66

77
m1 = client.get_map("m1").blocking()
88

9-
m1.put_all({
10-
"a": 1,
11-
"b": 2,
12-
"c": 3,
13-
"d": 4,
14-
"e": 5,
15-
"f": 6,
16-
"g": 7,
17-
})
9+
m1.put_all(
10+
{
11+
"a": 1,
12+
"b": 2,
13+
"c": 3,
14+
"d": 4,
15+
"e": 5,
16+
"f": 6,
17+
"g": 7,
18+
}
19+
)
1820

1921
size = m1.size()
2022
print("Added %s elements" % size)
@@ -39,6 +41,7 @@
3941
# server side and registered as a Portable or IdentifiedDataSerializable
4042
# before the server starts.
4143

44+
4245
class ReversedKeyComparator(IdentifiedDataSerializable):
4346
"""
4447
This class is simply a marker implementation
@@ -47,6 +50,7 @@ class ReversedKeyComparator(IdentifiedDataSerializable):
4750
server side. A sample server side implementation
4851
is provided at the end of file.
4952
"""
53+
5054
def get_class_id(self):
5155
return 1
5256

0 commit comments

Comments
 (0)