From 0b573366501fa7c79e8679e83fcd1d7c8b812f2d Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Wed, 6 Mar 2024 14:05:26 -0800 Subject: [PATCH] Format some things with black --- coq_tools/strip_comments.py | 21 ++++++++++++--------- pyproject.toml | 13 +++++++------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/coq_tools/strip_comments.py b/coq_tools/strip_comments.py index edff25b1..928df8ae 100644 --- a/coq_tools/strip_comments.py +++ b/coq_tools/strip_comments.py @@ -1,4 +1,5 @@ -__all__ = ['strip_comments'] +__all__ = ["strip_comments"] + def strip_comments(contents): """Strips the comments from coq code in contents. @@ -14,23 +15,25 @@ def strip_comments(contents): Note that we take some extra care to leave *) untouched when it does not terminate a comment. """ - contents = contents.replace('(*', ' (* ').replace('*)', ' *) ') - tokens = contents.split(' ') + contents = contents.replace("(*", " (* ").replace("*)", " *) ") + tokens = contents.split(" ") rtn = [] is_string = False comment_level = 0 for token in tokens: - do_append = (comment_level == 0) + do_append = comment_level == 0 if is_string: - if token.count('"') % 2 == 1: # there are an odd number of '"' characters, indicating that we've ended the string + if token.count('"') % 2 == 1: + # there are an odd number of '"' characters, indicating that we've ended the string is_string = False - elif token.count('"') % 2 == 1: # there are an odd number of '"' characters, so we're starting a string + elif token.count('"') % 2 == 1: + # there are an odd number of '"' characters, so we're starting a string is_string = True - elif token == '(*': + elif token == "(*": comment_level += 1 do_append = False - elif comment_level > 0 and token == '*)': + elif comment_level > 0 and token == "*)": comment_level -= 1 if do_append: rtn.append(token) - return ' '.join(rtn).replace(' (* ', '(*').replace(' *) ', '*)').strip('\n\t ') + return " ".join(rtn).replace(" (* ", "(*").replace(" *) ", "*)").strip("\n\t ") diff --git a/pyproject.toml b/pyproject.toml index b114218d..4ab369f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,14 @@ [project] name = "coq-tools" version = "0.0.5" -authors = [ - { name="Jason Gross", email="jgross@mit.edu" }, -] +authors = [{ name = "Jason Gross", email = "jgross@mit.edu" }] description = "Some scripts to help manipulate Coq developments and minimize error-producing Coq code" readme = "README.md" requires-python = ">=3.5" classifiers = [ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", ] [project.urls] @@ -20,3 +18,6 @@ classifiers = [ [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 120