chore: add black for all code, no string norm

This commit is contained in:
Henry Schreiner
2021-05-03 13:12:36 -04:00
committed by Henry Schreiner
parent 5716296071
commit 9cbed6a9be
12 changed files with 39 additions and 32 deletions
+1 -2
View File
@@ -19,10 +19,9 @@ repos:
- id: isort - id: isort
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 21.4b1 rev: 21.4b2
hooks: hooks:
- id: black - id: black
files: ^bin/update_pythons.py|setup.py$
- repo: https://github.com/asottile/setup-cfg-fmt - repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0 rev: v1.17.0
+1 -1
View File
@@ -180,7 +180,7 @@ def str_projects(
@click.option("--auth", help="GitHub authentication token") @click.option("--auth", help="GitHub authentication token")
@click.option("--readme", type=click.File("r+"), help="Modify a readme file if given") @click.option("--readme", type=click.File("r+"), help="Modify a readme file if given")
def projects( def projects(
input: TextIO, online: bool, auth: str | None, readme: TextIO | None input: TextIO, online: bool, auth: str | None, readme: TextIO | None,
) -> None: ) -> None:
config = yaml.safe_load(input) config = yaml.safe_load(input)
output = str_projects(config, online=online, auth=auth) output = str_projects(config, online=online, auth=auth)
+1 -1
View File
@@ -125,7 +125,7 @@ def run_example_ci_configs(config_files=None):
shutil.copyfile(src_config_file, dst_config_file) shutil.copyfile(src_config_file, dst_config_file)
run(['git', 'add', example_project], check=True) run(['git', 'add', example_project], check=True)
message = textwrap.dedent(f''' message = textwrap.dedent(f'''\
Test example minimal configs Test example minimal configs
Testing files: {config_files} Testing files: {config_files}
+1 -1
View File
@@ -22,6 +22,6 @@ if __name__ == '__main__':
subprocess.run([ subprocess.run([
sys.executable, '-m', 'test.test_projects', sys.executable, '-m', 'test.test_projects',
options.project_python_path, project_dir options.project_python_path, project_dir
], check=True) ], check=True,)
sys.exit(subprocess.run([sys.executable, '-m', 'cibuildwheel'], cwd=project_dir).returncode) sys.exit(subprocess.run([sys.executable, '-m', 'cibuildwheel'], cwd=project_dir).returncode)
+13 -8
View File
@@ -35,16 +35,21 @@ else:
for python_version in PYTHON_VERSIONS: for python_version in PYTHON_VERSIONS:
abi_flags = '' if int(python_version) >= 38 else 'm' abi_flags = '' if int(python_version) >= 38 else 'm'
python_path = f'/opt/python/cp{python_version}-cp{python_version}{abi_flags}/bin/' python_path = f'/opt/python/cp{python_version}-cp{python_version}{abi_flags}/bin/'
subprocess.run([ command = (
'docker', 'run', '--rm', f'{python_path}pip install pip-tools && '
'-e', 'CUSTOM_COMPILE_COMMAND', '{python_path}pip-compile --allow-unsafe --upgrade '
'-v', f'{os.getcwd()}:/volume',
'--workdir', '/volume', image_runner,
'bash', '-c',
f'{python_path}pip install pip-tools &&'
f'{python_path}pip-compile --allow-unsafe --upgrade '
'cibuildwheel/resources/constraints.in ' 'cibuildwheel/resources/constraints.in '
f'--output-file cibuildwheel/resources/constraints-python{python_version}.txt' f'--output-file cibuildwheel/resources/constraints-python{python_version}.txt'
)
subprocess.run([
'docker', 'run',
'--rm',
'--env=CUSTOM_COMPILE_COMMAND',
"--volume={os.getcwd()}:/volume",
'--workdir=/volume',
image_runner,
'bash', '-c',
command,
], check=True) ], check=True)
# default constraints.txt # default constraints.txt
+1 -1
View File
@@ -105,7 +105,7 @@ def main() -> None:
parser.add_argument('--allow-empty', parser.add_argument('--allow-empty',
action='store_true', action='store_true',
help='Do not report an error code if the build does not match any wheels.') help='Do not report an error code if the build does not match any wheels.',)
args = parser.parse_args() args = parser.parse_args()
+2 -2
View File
@@ -7,6 +7,6 @@ requires = [
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.black] [tool.black]
line-length = 120 line-length = 100
target-version = ['py36', 'py37', 'py38'] target-version = ['py36', 'py37', 'py38', 'py39']
skip-string-normalization = true skip-string-normalization = true
+1 -1
View File
@@ -52,7 +52,7 @@ include =
cibuildwheel cibuildwheel
[flake8] [flake8]
ignore = E501,W503,E741,E226,B950 ignore = E501,W503,E741,E226,B950,E203
select = C,E,F,W,B,B9 select = C,E,F,W,B,B9
application-import-names = cibuildwheel application-import-names = cibuildwheel
exclude = exclude =
+6 -4
View File
@@ -8,7 +8,7 @@ from .test_projects import TestProject
cpp_test_project = TestProject() cpp_test_project = TestProject()
cpp_test_project.files['setup.py'] = jinja2.Template(r''' setup_py_template = r'''\
from setuptools import Extension, setup from setuptools import Extension, setup
setup( setup(
@@ -16,9 +16,9 @@ setup(
ext_modules=[Extension('spam', sources=['spam.cpp'], language="c++", extra_compile_args={{ extra_compile_args }})], ext_modules=[Extension('spam', sources=['spam.cpp'], language="c++", extra_compile_args={{ extra_compile_args }})],
version="0.1.0", version="0.1.0",
) )
''') '''
cpp_test_project.files['spam.cpp'] = jinja2.Template(r''' spam_cpp_template = r'''\
#include <Python.h> #include <Python.h>
{{ spam_cpp_top_level_add }} {{ spam_cpp_top_level_add }}
@@ -69,8 +69,10 @@ MOD_INIT(spam)
MOD_RETURN(m) MOD_RETURN(m)
} }
''') '''
cpp_test_project.files['setup.py'] = jinja2.Template(setup_py_template)
cpp_test_project.files['spam.cpp'] = jinja2.Template(spam_cpp_template)
cpp11_project = cpp_test_project.copy() cpp11_project = cpp_test_project.copy()
cpp11_project.template_context['extra_compile_args'] = ( cpp11_project.template_context['extra_compile_args'] = (
+2 -2
View File
@@ -54,11 +54,11 @@ def test_pinned_versions(tmp_path, python_version):
if utils.platform == 'windows' and python_version == '2.7': if utils.platform == 'windows' and python_version == '2.7':
pytest.skip('Windows requires a workaround') pytest.skip('Windows requires a workaround')
is_running_on_macos_11_or_later = ( is_macos_11_or_later = (
utils.platform == 'macos' and utils.get_macos_version() >= (10, 16) utils.platform == 'macos' and utils.get_macos_version() >= (10, 16)
) )
if is_running_on_macos_11_or_later and python_version == '3.5': if is_macos_11_or_later and python_version == '3.5':
pytest.skip('CPython 3.5 doesn\'t work on macOS Big Sur+') pytest.skip('CPython 3.5 doesn\'t work on macOS Big Sur+')
project_dir = tmp_path / 'project' project_dir = tmp_path / 'project'
+4 -4
View File
@@ -8,10 +8,10 @@ from . import test_projects, utils
basic_project = test_projects.new_c_project() basic_project = test_projects.new_c_project()
ALL_MACOS_WHEELS = ( ALL_MACOS_WHEELS = {
utils.expected_wheels('spam', '0.1.0', machine_arch='x86_64') *utils.expected_wheels('spam', '0.1.0', machine_arch='x86_64'),
+ utils.expected_wheels('spam', '0.1.0', machine_arch='arm64') *utils.expected_wheels('spam', '0.1.0', machine_arch='arm64')
) }
def get_xcode_version() -> Tuple[int, int]: def get_xcode_version() -> Tuple[int, int]:
+2 -1
View File
@@ -64,7 +64,8 @@ def test(manylinux_image, tmp_path):
add_env['CIBW_SKIP'] = 'pp*' add_env['CIBW_SKIP'] = 'pp*'
elif manylinux_image in {'manylinux2014', 'manylinux_2_24'}: elif manylinux_image in {'manylinux2014', 'manylinux_2_24'}:
# We don't have a manylinux2014 / 'manylinux_2_24' image for PyPy (yet?) # We don't have a manylinux2014 / 'manylinux_2_24' image for PyPy (yet?)
add_env['CIBW_SKIP'] = 'cp27* pp*' # Python 2.7 not available on manylinux2014 / 'manylinux_2_24' # Python 2.7 not available on manylinux2014 / 'manylinux_2_24'
add_env['CIBW_SKIP'] = 'cp27* pp*'
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env) actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', manylinux_versions=[manylinux_image])] expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', manylinux_versions=[manylinux_image])]