8000 Use black for autogenerated portions of pyplot. remove textwrap usage · matplotlib/matplotlib@191b374 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 191b374

Browse files
committed
Use black for autogenerated portions of pyplot. remove textwrap usage
Add black to environment.yml testing deps for boilerplate test on Appveyor
1 parent 189e0a2 commit 191b374

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ dependencies:
6262
- pytest-xdist
6363
- tornado
6464
- pytz
65+
- black

requirements/testing/all.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pip requirements for all the CI builds
22

3+
black
34
certifi
45
coverage!=6.3
56
psutil

tools/boilerplate.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from inspect import Parameter
2020
from pathlib import Path
2121
import sys
22-
import textwrap
22+
import subprocess
23+
2324

2425
# This line imports the installed copy of matplotlib, and not the local copy.
2526
import numpy as np
@@ -151,10 +152,6 @@ def generate_function(name, called_fullname, template, **kwargs):
151152
**kwargs
152153
Additional parameters are passed to ``template.format()``.
153154
"""
154-
text_wrapper = textwrap.TextWrapper(
155-
break_long_words=False, width=70,
156-
initial_indent=' ' * 8, subsequent_indent=' ' * 8)
157-
158155
# Get signature of wrapped function.
159156
class_name, called_name = called_fullname.split('.')
160157
class_ = {'Axes': Axes, 'Figure': Figure}[class_name]
@@ -175,9 +172,6 @@ def generate_function(name, called_fullname, template, **kwargs):
175172
param.replace(default=value_formatter(param.default))
176173
if param.default is not param.empty else param
177174
for param in params]))
178-
if len('def ' + name + signature) >= 80 and False:
179-
# Move opening parenthesis before newline.
180-
signature = '(\n' + text_wrapper.fill(signature).replace('(', '', 1)
181175
# How to call the wrapped function.
182176
call = '(' + ', '.join((
183177
# Pass "intended-as-positional" parameters positionally to avoid
@@ -189,9 +183,6 @@ def generate_function(name, called_fullname, template, **kwargs):
189183
# Only pass the data kwarg if it is actually set, to avoid forcing
190184
# third-party subclasses to support it.
191185
'**({{"data": data}} if data is not None else {{}})'
192-
# Avoid linebreaks in the middle of the expression, by using \0 as a
193-
# placeholder that will be substituted after wrapping.
194-
.replace(' ', '\0')
195186
if param.name == "data" else
196187
'{0}={0}'
197188
if param.kind in [
@@ -205,9 +196,6 @@ def generate_function(name, called_fullname, template, **kwargs):
205196
if param.kind is Parameter.VAR_KEYWORD else
206197
None).format(param.name)
207198
for param in params) + ')'
208-
MAX_CALL_PREFIX = 18 # len(' __ret = gca().')
209-
if MAX_CALL_PREFIX + max(len(name), len(called_name)) + len(call) >= 80:
210-
call = '(\n' + text_wrapper.fill(call[1:]).replace('\0', ' ')
211199
# Bail out in case of name collision.
212200
for reserved in ('gca', 'gci', 'gcf', '__ret'):
213201
if reserved in params:
@@ -395,6 +383,11 @@ def build_pyplot(pyplot_path):
395383
pyplot.writelines(pyplot_orig)
396384
pyplot.writelines(boilerplate_gen())
397385

386+
# Run black to autoformat pyplot
387+
subprocess.run(
388+
[sys.executable, "-m", "black", "--line-length=79", pyplot_path]
389+
)
390+
398391

399392
### Methods for retrieving signatures from pyi stub files
400393

0 commit comments

Comments
 (0)
0