Skip to content

Commit 26c9219

Browse files
authored
Merge pull request #99 from gramaziokohler/black
⚫ Switch to black
2 parents 8196200 + fb9cdca commit 26c9219

28 files changed

+683
-749
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ insert_final_newline = true
88
indent_style = space
99
indent_size = 4
1010
charset = utf-8
11-
max_line_length = 180
11+
max_line_length = 120
1212

1313
[*.{bat,cmd,ps1}]
1414
end_of_line = crlf

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Unreleased
1414

1515
**Changed**
1616

17+
* Switched to ``black`` for python code formatting.
18+
1719
**Fixed**
1820

1921
**Deprecated**

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ include CONTRIBUTING.rst
1414
include ISSUE_TEMPLATE.md
1515
include LICENSE
1616
include README.rst
17+
include pyproject.toml
1718

1819
include requirements-dev.txt tasks.py pytest.ini
1920

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[tool.black]
2+
line-length = 120
3+
extend-exclude = "src/roslibpy/comm/comm_cli.py"
4+
5+
[tool.pytest.ini_options]
6+
minversion = "6.0"
7+
testpaths = ["tests"]
8+
python_files = [
9+
"test_*.py",
10+
"*_test.py",
11+
"tests.py"
12+
]
13+
addopts = "-ra --strict --doctest-modules --doctest-glob=*.rst --tb=short"
14+
doctest_optionflags= "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ALLOW_UNICODE ALLOW_BYTES"
15+
filterwarnings = "ignore::DeprecationWarning"
16+
17+
[tool.isort]
18+
# These settings -including the shorter-than-the rest- line length avoid
19+
# conflicts between isort and black import formatting
20+
line_length = 88
21+
multi_line_output = 3
22+
include_trailing_comma = true
23+
force_grid_wrap = 0
24+
use_parentheses = true
25+
ensure_newline_before_comments = true
26+
known_first_party = "roslibpy"
27+
default_section = "THIRDPARTY"
28+
forced_separate = "test_roslibpy"

pytest.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.

requirements-dev.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
attrs>=19.2.0
2-
autopep8
2+
black
33
bump2version >=1.0.1
44
check-manifest>=0.36
55
doc8
66
flake8
77
invoke>=0.14
8-
isort>=4.3.21
8+
isort
99
pydocstyle
10-
pytest
10+
pytest>=6.0
1111
sphinx >=3.4
1212
twine
1313
-e .

setup.cfg

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,6 @@
22
universal = 1
33

44
[flake8]
5-
max-line-length = 180
5+
max-line-length = 120
66
exclude = */migrations/*
77

8-
[tool:pytest]
9-
testpaths = tests
10-
norecursedirs =
11-
migrations
12-
13-
python_files =
14-
test_*.py
15-
*_test.py
16-
tests.py
17-
addopts =
18-
-ra
19-
--strict
20-
--doctest-modules
21-
--doctest-glob=\*.rst
22-
--tb=short
23-
24-
[isort]
25-
force_single_line = True
26-
line_length = 180
27-
known_first_party = roslibpy
28-
default_section = THIRDPARTY
29-
forced_separate = test_roslibpy
30-
skip = migrations, __init__.py

setup.py

Lines changed: 40 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,71 @@
11
#!/usr/bin/env python
22
# -*- encoding: utf-8 -*-
3-
from __future__ import absolute_import
4-
from __future__ import print_function
3+
from __future__ import absolute_import, print_function
54

65
import io
76
import re
87
import sys
98
from glob import glob
10-
from os.path import abspath
11-
from os.path import basename
12-
from os.path import dirname
13-
from os.path import join
14-
from os.path import splitext
9+
from os.path import abspath, basename, dirname, join, splitext
1510

16-
from setuptools import find_packages
17-
from setuptools import setup
11+
from setuptools import find_packages, setup
1812

1913
here = abspath(dirname(__file__))
2014

2115
# If IronPython, we don't require autobahn/twisted
2216
if sys.platform == "cli":
2317
requirements = []
2418
else:
25-
requirements = [
26-
'autobahn>=17.10',
27-
'twisted>=17.9'
28-
]
19+
requirements = ["autobahn>=17.10", "twisted>=17.9"]
2920

3021

3122
def read(*names, **kwargs):
32-
return io.open(
33-
join(here, *names),
34-
encoding=kwargs.get('encoding', 'utf8')
35-
).read()
23+
return io.open(join(here, *names), encoding=kwargs.get("encoding", "utf8")).read()
3624

3725

3826
about = {}
39-
exec(read('src', 'roslibpy', '__version__.py'), about)
27+
exec(read("src", "roslibpy", "__version__.py"), about)
4028

4129
setup(
42-
name=about['__title__'],
43-
version=about['__version__'],
44-
license=about['__license__'],
45-
description=about['__description__'],
46-
author=about['__author__'],
47-
author_email=about['__author_email__'],
48-
url=about['__url__'],
49-
long_description='%s\n%s' % (
50-
re.compile('^.. start-badges.*^.. end-badges', re.M |
51-
re.S).sub('', read('README.rst')),
52-
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))
30+
name=about["__title__"],
31+
version=about["__version__"],
32+
license=about["__license__"],
33+
description=about["__description__"],
34+
author=about["__author__"],
35+
author_email=about["__author_email__"],
36+
url=about["__url__"],
37+
long_description="%s\n%s"
38+
% (
39+
re.compile("^.. start-badges.*^.. end-badges", re.M | re.S).sub("", read("README.rst")),
40+
re.sub(":[a-z]+:`~?(.*?)`", r"``\1``", read("CHANGELOG.rst")),
5341
),
54-
packages=find_packages('src'),
55-
package_dir={'': 'src'},
56-
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
42+
packages=find_packages("src"),
43+
package_dir={"": "src"},
44+
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
5745
include_package_data=True,
5846
zip_safe=False,
5947
classifiers=[
60-
'Development Status :: 4 - Beta',
61-
'Intended Audience :: Developers',
62-
'Intended Audience :: Science/Research',
63-
'License :: OSI Approved :: MIT License',
64-
'Operating System :: Unix',
65-
'Operating System :: POSIX',
66-
'Operating System :: Microsoft :: Windows',
67-
'Programming Language :: Python',
68-
'Programming Language :: Python :: 3',
69-
'Programming Language :: Python :: 3.3',
70-
'Programming Language :: Python :: 3.4',
71-
'Programming Language :: Python :: 3.5',
72-
'Programming Language :: Python :: 3.6',
73-
'Programming Language :: Python :: 3.7',
74-
'Programming Language :: Python :: 3.8',
75-
'Programming Language :: Python :: Implementation :: CPython',
76-
'Programming Language :: Python :: Implementation :: IronPython',
77-
'Topic :: Scientific/Engineering',
48+
"Development Status :: 4 - Beta",
49+
"Intended Audience :: Developers",
50+
"Intended Audience :: Science/Research",
51+
"License :: OSI Approved :: MIT License",
52+
"Operating System :: Unix",
53+
"Operating System :: POSIX",
54+
"Operating System :: Microsoft :: Windows",
55+
"Programming Language :: Python",
56+
"Programming Language :: Python :: 3",
57+
"Programming Language :: Python :: 3.3",
58+
"Programming Language :: Python :: 3.4",
59+
"Programming Language :: Python :: 3.5",
60+
"Programming Language :: Python :: 3.6",
61+
"Programming Language :: Python :: 3.7",
62+
"Programming Language :: Python :: 3.8",
63+
"Programming Language :: Python :: Implementation :: CPython",
64+
"Programming Language :: Python :: Implementation :: IronPython",
65+
"Topic :: Scientific/Engineering",
7866
],
79-
keywords=['ros', 'ros-bridge', 'robotics', 'websockets'],
67+
keywords=["ros", "ros-bridge", "robotics", "websockets"],
8068
install_requires=requirements,
8169
extras_require={},
82-
entry_points={
83-
'console_scripts': [
84-
'roslibpy=roslibpy.__main__:main'
85-
]
86-
},
70+
entry_points={"console_scripts": ["roslibpy=roslibpy.__main__:main"]},
8771
)

src/roslibpy/__init__.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class and are passed around via :class:`Topics <Topic>` using a **publish/subscr
9898
__license__,
9999
__title__,
100100
__url__,
101-
__version__
101+
__version__,
102102
)
103103
from .core import (
104104
Header,
@@ -108,32 +108,27 @@ class and are passed around via :class:`Topics <Topic>` using a **publish/subscr
108108
ServiceRequest,
109109
ServiceResponse,
110110
Time,
111-
Topic
112-
)
113-
from .ros import (
114-
set_rosapi_timeout,
115-
Ros
111+
Topic,
116112
)
113+
from .ros import Ros, set_rosapi_timeout
117114

118115
__all__ = [
119-
'__author__',
120-
'__author_email__',
121-
'__copyright__',
122-
'__description__',
123-
'__license__',
124-
'__title__',
125-
'__url__',
126-
'__version__',
127-
128-
'Header',
129-
'Message',
130-
'Param',
131-
'Service',
132-
'ServiceRequest',
133-
'ServiceResponse',
134-
'Time',
135-
'Topic',
136-
137-
'set_rosapi_timeout',
138-
'Ros',
116+
"__author__",
117+
"__author_email__",
118+
"__copyright__",
119+
"__description__",
120+
"__license__",
121+
"__title__",
122+
"__url__",
123+
"__version__",
124+
"Header",
125+
"Message",
126+
"Param",
127+
"Service",
128+
"ServiceRequest",
129+
"ServiceResponse",
130+
"Time",
131+
"Topic",
132+
"set_rosapi_timeout",
133+
"Ros",
139134
]

0 commit comments

Comments
 (0)