diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6cd77e3..f16a239 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,15 +4,15 @@ repos: - repo: https://github.com/python/black - rev: 19.10b0 + rev: 21.6b0 hooks: - id: black - repo: https://github.com/fsfe/reuse-tool - rev: latest + rev: v0.12.1 hooks: - id: reuse - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v4.0.1 hooks: - id: check-yaml - id: end-of-file-fixer diff --git a/adafruit_shell.py b/adafruit_shell.py index e6db97d..f5c7ef1 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -55,7 +55,11 @@ def select_n(message, selections): for index, selection in enumerate(selections): options.append( - {"selector": str(index + 1), "prompt": selection, "return": index + 1,} + { + "selector": str(index + 1), + "prompt": selection, + "return": index + 1, + } ) return prompt.options(message, options) @@ -66,9 +70,11 @@ def run_command(self, cmd, suppress_message=False, return_output=False): original_stdout = sys.stdout original_stderr = sys.stderr try: + # pylint: disable=consider-using-with proc = subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) + # pylint: enable=consider-using-with full_output = "" while True: output = proc.stdout.readline() @@ -391,9 +397,8 @@ def write_text_file(self, path, content, append=True): content = "\n" + content else: mode = "w" - service_file = open(self.path(path), mode) - service_file.write(content) - service_file.close() + with open(self.path(path), mode) as service_file: + service_file.write(content) @staticmethod def is_python3(): diff --git a/setup.py b/setup.py index 49f407e..90a2725 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,10 @@ # Author details author="Adafruit Industries", author_email="circuitpython@adafruit.com", - install_requires=["clint", "Adafruit-PlatformDetect",], + install_requires=[ + "clint", + "Adafruit-PlatformDetect", + ], # Choose your license license="MIT", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers