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

add automatic code format enforcer - black #813

Merged
merged 8 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: v1.1.1
rev: v1.2.3
hooks:
- id: trailing-whitespace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary with black anymore, I guess.

- id: end-of-file-fixer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

- id: check-yaml
- id: debug-statements
- id: flake8
- repo: https://github.com/ambv/black
rev: stable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, and yeah I agree about the quotes; but at the end of day I prefer consistency over which of the two :-)

hooks:
- id: black
args: [--line-length=99, --safe]
python_version: python3.6
- repo: https://github.com/asottile/pyupgrade
sha: v1.2.0
rev: v1.2.0
hooks:
- id: pyupgrade
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
.. image:: https://readthedocs.org/projects/tox/badge/?version=latest
:target: http://tox.readthedocs.io/en/latest/?badge=latest
:alt: Documentation status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
:alt: Code style: black
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess that is the case now :)


tox automation project
======================
Expand Down
66 changes: 34 additions & 32 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,59 @@
from pkg_resources import get_distribution

sys.path.insert(0, os.path.dirname(__file__))
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode']
extensions = [
"sphinx.ext.autodoc", "sphinx.ext.extlinks", "sphinx.ext.intersphinx", "sphinx.ext.viewcode"
]

project = u'tox'
project = u"tox"
_full_version = get_distribution(project).version
release = _full_version.split('+', 1)[0]
version = '.'.join(release.split('.')[:2])
release = _full_version.split("+", 1)[0]
version = ".".join(release.split(".")[:2])

author = 'holger krekel and others'
author = "holger krekel and others"
year = date.today().year
copyright = u'2010-{}, {}'.format(year, author)
copyright = u"2010-{}, {}".format(year, author)

master_doc = 'index'
source_suffix = '.rst'
master_doc = "index"
source_suffix = ".rst"

exclude_patterns = ['_build']
exclude_patterns = ["_build"]

templates_path = ['_templates']
pygments_style = 'sphinx'
html_theme = 'alabaster'
html_logo = 'img/tox.png'
html_favicon = 'img/toxfavi.ico'
html_static_path = ['_static']
templates_path = ["_templates"]
pygments_style = "sphinx"
html_theme = "alabaster"
html_logo = "img/tox.png"
html_favicon = "img/toxfavi.ico"
html_static_path = ["_static"]
html_show_sourcelink = False
htmlhelp_basename = '{}doc'.format(project)
latex_documents = [('index', 'tox.tex', u'{} Documentation'.format(project),
author, 'manual')]
man_pages = [('index', project, u'{} Documentation'.format(project),
[author], 1)]
htmlhelp_basename = "{}doc".format(project)
latex_documents = [("index", "tox.tex", u"{} Documentation".format(project), author, "manual")]
man_pages = [("index", project, u"{} Documentation".format(project), [author], 1)]
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {"https://docs.python.org/": None}


def setup(app):
# from sphinx.ext.autodoc import cut_lines
# app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_description_unit('confval', 'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value')
app.add_description_unit(
"confval",
"confval",
objname="configuration value",
indextemplate="pair: %s; configuration value",
)


tls_cacerts = os.getenv('SSL_CERT_FILE') # we don't care here about the validity of certificates
tls_cacerts = os.getenv("SSL_CERT_FILE") # we don't care here about the validity of certificates
linkcheck_timeout = 30
linkcheck_ignore = [r'http://holgerkrekel.net']
linkcheck_ignore = [r"http://holgerkrekel.net"]

extlinks = {'issue': ('https://github.com/tox-dev/tox/issues/%s', '#'),
'pull': ('https://github.com/tox-dev/tox/pull/%s', 'p'),
'user': ('https://github.com/%s', '@')}
extlinks = {
"issue": ("https://github.com/tox-dev/tox/issues/%s", "#"),
"pull": ("https://github.com/tox-dev/tox/pull/%s", "p"),
"user": ("https://github.com/%s", "@"),
}
91 changes: 45 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,65 @@ def has_environment_marker_support():
* https://www.python.org/dev/peps/pep-0426/#environment-markers
"""
import pkg_resources

try:
v = pkg_resources.parse_version(setuptools.__version__)
return v >= pkg_resources.parse_version('0.7.2')
return v >= pkg_resources.parse_version("0.7.2")
except Exception as e:
sys.stderr.write("Could not test setuptool's version: %s\n" % e)
sys.stderr.write("Could not test setuptool's version: {}\n".format(e))
return False


def get_long_description():
with io.open('README.rst', encoding='utf-8') as f:
with io.open('CHANGELOG.rst', encoding='utf-8') as g:
return "%s\n\n%s" % (f.read(), g.read())
with io.open("README.rst", encoding="utf-8") as f:
with io.open("CHANGELOG.rst", encoding="utf-8") as g:
return "{}\n\n{}".format(f.read(), g.read())


def main():
setuptools.setup(
name='tox',
description='virtualenv-based automation of test activities',
name="tox",
description="virtualenv-based automation of test activities",
long_description=get_long_description(),
url='https://tox.readthedocs.org/',
url="https://tox.readthedocs.org/",
use_scm_version=True,
license='http://opensource.org/licenses/MIT',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
author_email='[email protected]',
packages=['tox'],
entry_points={'console_scripts': ['tox=tox:cmdline',
'tox-quickstart=tox._quickstart:main']},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
setup_requires=['setuptools_scm'],
install_requires=['py>=1.4.17',
'pluggy>=0.3.0,<1.0',
'six',
'virtualenv>=1.11.2'],
extras_require={'testing': ['pytest >= 3.0.0',
'pytest-cov',
'pytest-mock',
'pytest-timeout',
'pytest-xdist'],
'docs': ['sphinx >= 1.6.3, < 2',
'towncrier >= 17.8.0'],
'lint': ['flake8 == 3.4.1',
'flake8-bugbear == 17.4.0',
'pre-commit == 1.4.4'],
'publish': ['devpi',
'twine']},
classifiers=['Development Status :: 5 - Production/Stable',
'Framework :: tox',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS :: MacOS X',
'Topic :: Software Development :: Testing',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities'] + [
('Programming Language :: Python :: {}'.format(x)) for
x in '2 2.7 3 3.4 3.5 3.6'.split()]
license="http://opensource.org/licenses/MIT",
platforms=["unix", "linux", "osx", "cygwin", "win32"],
author="holger krekel",
author_email="[email protected]",
packages=["tox"],
entry_points={
"console_scripts": ["tox=tox:cmdline", "tox-quickstart=tox._quickstart:main"]
},
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
setup_requires=["setuptools_scm"],
install_requires=["py>=1.4.17", "pluggy>=0.3.0,<1.0", "six", "virtualenv>=1.11.2"],
extras_require={
"testing": [
"pytest >= 3.0.0", "pytest-cov", "pytest-mock", "pytest-timeout", "pytest-xdist"
],
"docs": ["sphinx >= 1.6.3, < 2", "towncrier >= 17.8.0"],
"lint": ["flake8 == 3.5.0", "flake8-bugbear == 18.2.0", "pre-commit == 1.8.2"],
"publish": ["devpi", "twine"],
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Framework :: tox",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS :: MacOS X",
"Topic :: Software Development :: Testing",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
]
+ [
("Programming Language :: Python :: {}".format(x))
for x in "2 2.7 3 3.4 3.5 3.6".split()
],
)


if __name__ == '__main__':
if __name__ == "__main__":
main()
20 changes: 10 additions & 10 deletions tasks/pre-process-changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ def include_draft_newsfragments():
current_path = os.getcwd()
try:
os.chdir(project_root)
cmd = ['towncrier', '--draft', '--dir', project_root]
out = subprocess.check_output(cmd).decode('utf-8').strip()
docs_build_dir = project_root / '.tox' / 'docs' / 'fragments.rst'
cmd = ["towncrier", "--draft", "--dir", project_root]
out = subprocess.check_output(cmd).decode("utf-8").strip()
docs_build_dir = project_root / ".tox" / "docs" / "fragments.rst"
docs_build_dir.write(out)
finally:
os.chdir(current_path)


def manipulate_the_news():
home = 'https://github.com'
issue = '%s/issue' % home
fragmentsPath = Path(__file__).parents[1] / 'tox' / 'changelog'
home = "https://github.com"
issue = "%s/issue" % home
fragmentsPath = Path(__file__).parents[1] / "tox" / "changelog"
for pattern, replacement in (
(r'[^`]@([^,\s]+)', r'`@\1 <%s/\1>`_' % home),
(r'[^`]#([\d]+)', r'`#pr\1 <%s/\1>`_' % issue),
(r"[^`]@([^,\s]+)", r"`@\1 <%s/\1>`_" % home),
(r"[^`]#([\d]+)", r"`#pr\1 <%s/\1>`_" % issue),
):
for path in fragmentsPath.glob('*.rst'):
for path in fragmentsPath.glob("*.rst"):
path.write_text(re.sub(pattern, replacement, path.read_text()))


main = manipulate_the_news


if __name__ == '__main__':
if __name__ == "__main__":
sys.exit(main())
Loading