mirror of
https://github.com/esphome/esphome.git
synced 2025-06-18 22:35:40 +01:00
Raise minimum python version to 3.8 (#3176)
This commit is contained in:
.github/workflows
.gitignore.pre-commit-config.yamlesphome
requirements_test.txtscript
setup.py@ -1,7 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import print_function
|
||||
from helpers import styled, print_error_for_file, get_output, get_err, git_ls_files, filter_changed
|
||||
from helpers import (
|
||||
styled,
|
||||
print_error_for_file,
|
||||
get_output,
|
||||
get_err,
|
||||
git_ls_files,
|
||||
filter_changed,
|
||||
)
|
||||
import argparse
|
||||
import colorama
|
||||
import os
|
||||
@ -34,6 +40,12 @@ def main():
|
||||
parser.add_argument(
|
||||
"-c", "--changed", action="store_true", help="Only run on changed files"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--apply",
|
||||
action="store_true",
|
||||
help="Apply changes to files where possible",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
files = []
|
||||
@ -56,7 +68,7 @@ def main():
|
||||
|
||||
errors = 0
|
||||
|
||||
cmd = ["black", "--verbose", "--check"] + files
|
||||
cmd = ["black", "--verbose"] + ([] if args.apply else ["--check"]) + files
|
||||
print("Running black...")
|
||||
print()
|
||||
log = get_err(*cmd)
|
||||
@ -97,6 +109,21 @@ def main():
|
||||
print_error(file_, linno, msg)
|
||||
errors += 1
|
||||
|
||||
PYUPGRADE_TARGET = "--py38-plus"
|
||||
cmd = ["pyupgrade", PYUPGRADE_TARGET] + files
|
||||
print()
|
||||
print("Running pyupgrade...")
|
||||
print()
|
||||
log = get_err(*cmd)
|
||||
for line in log.splitlines():
|
||||
REWRITING = "Rewriting"
|
||||
if line.startswith(REWRITING):
|
||||
file_ = line[len(REWRITING) + 1 :]
|
||||
print_error(
|
||||
file_, None, f"Please run pyupgrade {PYUPGRADE_TARGET} on this file"
|
||||
)
|
||||
errors += 1
|
||||
|
||||
sys.exit(errors)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user