From 9dd0663159822348b8e74282c0cc8fa91d6273e8 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:04:18 -0400 Subject: [PATCH 01/21] raw strings for \d --- doc/source/vendor/youtube.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/vendor/youtube.py b/doc/source/vendor/youtube.py index 10bbc8f..4795a89 100644 --- a/doc/source/vendor/youtube.py +++ b/doc/source/vendor/youtube.py @@ -17,7 +17,7 @@ def get_size(d, key): if key not in d: return None - m = re.match("(\d+)(|%|px)$", d[key]) + m = re.match(r"(\d+)(|%|px)$", d[key]) if not m: raise ValueError("invalid size %r" % d[key]) return int(m.group(1)), m.group(2) or "px" @@ -107,7 +107,7 @@ class YouTube(Directive): def run(self): if "aspect" in self.options: aspect = self.options.get("aspect") - m = re.match("(\d+):(\d+)", aspect) + m = re.match(r"(\d+):(\d+)", aspect) if m is None: raise ValueError("invalid aspect ratio %r" % aspect) aspect = tuple(int(x) for x in m.groups()) From 63990317f82f986dcc1c2093d921cf23b0396361 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:09:13 -0400 Subject: [PATCH 02/21] fixing imports and jinja issue --- doc/source/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index ae98f81..4e24c4d 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -20,6 +20,8 @@ import os import sys +import sphinx_rtd_theme + sys.path.insert(0, os.path.abspath("vendor")) @@ -107,7 +109,6 @@ # a list of builtin themes. # html_theme = "sphinx_rtd_theme" -import sphinx_rtd_theme html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] From 443939a113c94fd80ab61c41bfa40b90de917614 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:20:41 -0400 Subject: [PATCH 03/21] black ignore problematic jinja templated py files --- pyproject.toml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9cf283a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[tool.black] +line-length = 115 +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | \doc\source\conf.py + + # The following are specific to Black, you probably don't want those. + | blib2to3 + | tests/data +)/ +''' From c6bf04169cb0b8645ce3357b6ad6b6d3b13b7908 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:21:31 -0400 Subject: [PATCH 04/21] black ignore problematic jinja templated setup.py files --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9cf283a..f714b97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ exclude = ''' | build | dist | \doc\source\conf.py + | \{{ cookiecutter.repo_nanme }}/setup.py' # The following are specific to Black, you probably don't want those. | blib2to3 From a690882c4056c02c2e6f0986c57ef37131c04154 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:23:37 -0400 Subject: [PATCH 05/21] trying to fix typo in black exclude, but not failing locally so have to push --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f714b97..deb89ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ exclude = ''' | build | dist | \doc\source\conf.py - | \{{ cookiecutter.repo_nanme }}/setup.py' + | \{{ cookiecutter.repo_nanme }}/setup.py # The following are specific to Black, you probably don't want those. | blib2to3 From 4c1c601e2f884bae31e860ed25ac1dd68a51259d Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:25:38 -0400 Subject: [PATCH 06/21] trying to fix typo in black exclude, but not failing locally so have to push --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index deb89ae..9cf283a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ exclude = ''' | build | dist | \doc\source\conf.py - | \{{ cookiecutter.repo_nanme }}/setup.py # The following are specific to Black, you probably don't want those. | blib2to3 From eb0cce24323b6785dcb333816fad53ec57cc2613 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:27:24 -0400 Subject: [PATCH 07/21] trying to fix typo in black exclude, but not failing locally so have to push --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9cf283a..cc760f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ exclude = ''' | buck-out | build | dist - | \doc\source\conf.py + | doc\source\conf.py # The following are specific to Black, you probably don't want those. | blib2to3 From accb1884a2a7303e39b0f996ca9327d175f30fa0 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:31:05 -0400 Subject: [PATCH 08/21] trying to fix typo in black exclude, but not failing locally so have to push --- .flake8 | 2 ++ pyproject.toml | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 0b351c0..160f8fc 100644 --- a/.flake8 +++ b/.flake8 @@ -7,6 +7,8 @@ exclude = versioneer.py, labpdfproc/_version.py, doc/manual/source/conf.py + {{ cookiecutter.repo_name }}/setup.py + {{ cookiecutter.repo_name }}/doc/source/conf.py max-line-length = 115 # Ignore some style 'errors' produced while formatting by 'black' (see link below) # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings diff --git a/pyproject.toml b/pyproject.toml index cc760f0..3239179 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ exclude = ''' | buck-out | build | dist - | doc\source\conf.py # The following are specific to Black, you probably don't want those. | blib2to3 From dae076afb2119ca598d59ad1da718a7bd534ad26 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 20:31:19 +0000 Subject: [PATCH 09/21] [pre-commit.ci] auto fixes from pre-commit hooks --- doc/source/vendor/youtube.py | 7 ++----- {{ cookiecutter.repo_name }}/setup.py | 6 +----- .../{{ cookiecutter.package_dir_name }}/version.py | 9 ++------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/doc/source/vendor/youtube.py b/doc/source/vendor/youtube.py index 4795a89..ca73de7 100644 --- a/doc/source/vendor/youtube.py +++ b/doc/source/vendor/youtube.py @@ -88,8 +88,7 @@ def depart_youtube_node(self, node): def visit_youtube_node_latex(self, node): self.body.append( - r"\begin{quote}\begin{center}\fbox{\url{https://www.youtu.be/%s}}\end{center}\end{quote}" - % node["id"] + r"\begin{quote}\begin{center}\fbox{\url{https://www.youtu.be/%s}}\end{center}\end{quote}" % node["id"] ) @@ -115,9 +114,7 @@ def run(self): aspect = None width = get_size(self.options, "width") height = get_size(self.options, "height") - return [ - youtube(id=self.arguments[0], aspect=aspect, width=width, height=height) - ] + return [youtube(id=self.arguments[0], aspect=aspect, width=width, height=height)] def unsupported_visit_youtube(self, node): diff --git a/{{ cookiecutter.repo_name }}/setup.py b/{{ cookiecutter.repo_name }}/setup.py index e7cf5af..546081e 100644 --- a/{{ cookiecutter.repo_name }}/setup.py +++ b/{{ cookiecutter.repo_name }}/setup.py @@ -34,11 +34,7 @@ with open(path.join(here, "requirements.txt")) as requirements_file: # Parse requirements.txt, ignoring any commented-out lines. - requirements = [ - line - for line in requirements_file.read().splitlines() - if not line.startswith("#") - ] + requirements = [line for line in requirements_file.read().splitlines() if not line.startswith("#")] setup( diff --git a/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py b/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py index 29026d6..15488a1 100644 --- a/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py +++ b/{{ cookiecutter.repo_name }}/src/diffpy/{{ cookiecutter.package_dir_name }}/version.py @@ -131,10 +131,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): root = os.path.dirname(root) # up a level if verbose: - print( - "Tried directories %s but none started with prefix %s" - % (str(rootdirs), parentdir_prefix) - ) + print("Tried directories %s but none started with prefix %s" % (str(rootdirs), parentdir_prefix)) raise NotThisMethod("rootdir doesn't start with parentdir_prefix") @@ -322,9 +319,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): pieces["distance"] = int(count_out) # total number of commits # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ - 0 - ].strip() + date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) return pieces From 217d89efb133d4b7211c94a702f3ac84aa360da0 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:34:42 -0400 Subject: [PATCH 10/21] trying to fix typo in black exclude, but not failing locally so have to push --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 3239179..6176f13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ exclude = ''' | buck-out | build | dist + | doc/source/conf\.py # The following are specific to Black, you probably don't want those. | blib2to3 From 9d6126477b9fd9c2d97941499793cb3282d92576 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:54:32 -0400 Subject: [PATCH 11/21] try again --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6176f13..ccecef1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,9 +12,7 @@ exclude = ''' | buck-out | build | dist - | doc/source/conf\.py - - # The following are specific to Black, you probably don't want those. + | \{\{ cookiecutter\.repo_name \}\}/doc/source/conf\.py | blib2to3 | tests/data )/ From 453bea6c386b96fcb81316684112fb5867e93e7b Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 16:57:25 -0400 Subject: [PATCH 12/21] adding commas to flake8 exclude --- .flake8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 160f8fc..bca4e01 100644 --- a/.flake8 +++ b/.flake8 @@ -6,8 +6,8 @@ exclude = dist, versioneer.py, labpdfproc/_version.py, - doc/manual/source/conf.py - {{ cookiecutter.repo_name }}/setup.py + doc/manual/source/conf.py, + {{ cookiecutter.repo_name }}/setup.py, {{ cookiecutter.repo_name }}/doc/source/conf.py max-line-length = 115 # Ignore some style 'errors' produced while formatting by 'black' (see link below) From 5a9a16f5a8deb78b371a5e02c2e91bcb83b92d20 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 17:07:16 -0400 Subject: [PATCH 13/21] last try, but I am stumped --- .flake8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index bca4e01..26ddd4e 100644 --- a/.flake8 +++ b/.flake8 @@ -7,8 +7,8 @@ exclude = versioneer.py, labpdfproc/_version.py, doc/manual/source/conf.py, - {{ cookiecutter.repo_name }}/setup.py, - {{ cookiecutter.repo_name }}/doc/source/conf.py + ./{{ cookiecutter.repo_name }}/setup.py, + ./{{ cookiecutter.repo_name }}/doc/source/conf.py max-line-length = 115 # Ignore some style 'errors' produced while formatting by 'black' (see link below) # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings From d96fd078e101dcebc9f78ad9b2ff143cf6e4d01f Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 17:39:53 -0400 Subject: [PATCH 14/21] **/setup.py to get them all excluded in flake8 and black --- .flake8 | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.flake8 b/.flake8 index 26ddd4e..a52b5af 100644 --- a/.flake8 +++ b/.flake8 @@ -7,8 +7,8 @@ exclude = versioneer.py, labpdfproc/_version.py, doc/manual/source/conf.py, - ./{{ cookiecutter.repo_name }}/setup.py, - ./{{ cookiecutter.repo_name }}/doc/source/conf.py + **/setup.py, + **/doc/source/conf.py max-line-length = 115 # Ignore some style 'errors' produced while formatting by 'black' (see link below) # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings diff --git a/pyproject.toml b/pyproject.toml index ccecef1..1f4b302 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ exclude = ''' | buck-out | build | dist - | \{\{ cookiecutter\.repo_name \}\}/doc/source/conf\.py + | **/doc/source/conf\.py | blib2to3 | tests/data )/ From b9e94fef70b2b1b3eb0bf2c4d8c47e2d1dd8685a Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 17:42:26 -0400 Subject: [PATCH 15/21] try again --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1f4b302..b67006d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ exclude = ''' | buck-out | build | dist - | **/doc/source/conf\.py + | .*/doc/source/conf\.py | blib2to3 | tests/data )/ From 21cc8740f155e836a9a07a1fb269fbd2a449243e Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 17:45:23 -0400 Subject: [PATCH 16/21] try again --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b67006d..203d722 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ exclude = ''' | buck-out | build | dist - | .*/doc/source/conf\.py + | \.*/doc/source/conf\.py | blib2to3 | tests/data )/ From 32134e8ae2e1750f7cdeb09364159d72e665d3e2 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Wed, 19 Jun 2024 17:53:22 -0400 Subject: [PATCH 17/21] try again --- pyproject.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 203d722..3480d92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,12 +8,12 @@ exclude = ''' | \.mypy_cache | \.tox | \.venv - | _build + | _build/ | buck-out - | build - | dist - | \.*/doc/source/conf\.py + | build/ + | dist/ | blib2to3 - | tests/data + | tests/data/ + | .*conf\.py$ )/ ''' From fcb5bc8318777bbe4f0357e07cd51fc819bac120 Mon Sep 17 00:00:00 2001 From: Sparky <59151395+Sparks29032@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:57:26 -0400 Subject: [PATCH 18/21] Add back setup.py, add cookiecutter builtins --- .flake8 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.flake8 b/.flake8 index a52b5af..6295bfb 100644 --- a/.flake8 +++ b/.flake8 @@ -4,11 +4,9 @@ exclude = __pycache__, build, dist, - versioneer.py, - labpdfproc/_version.py, - doc/manual/source/conf.py, - **/setup.py, - **/doc/source/conf.py + doc/source/conf.py, + */doc/source/conf.py +builtins = cookiecutter max-line-length = 115 # Ignore some style 'errors' produced while formatting by 'black' (see link below) # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings From 5279191c047a37553419f61fe29a1f5201feec9c Mon Sep 17 00:00:00 2001 From: Sparky <59151395+Sparks29032@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:57:57 -0400 Subject: [PATCH 19/21] Black regex exclude --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3480d92..27a63de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,9 @@ exclude = ''' | \.venv | _build/ | buck-out - | build/ - | dist/ + | build + | dist + | ./doc/source/conf\.py | blib2to3 | tests/data/ | .*conf\.py$ From e6f7747eedb71cd3e1f7680f5346b33105c8de09 Mon Sep 17 00:00:00 2001 From: Sparky <59151395+Sparks29032@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:03:52 -0400 Subject: [PATCH 20/21] Propagate exclude to pre-commit --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c458806..e70ab2d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,7 @@ repos: rev: 24.4.2 hooks: - id: black + args: ["--exclude", "./doc/source/conf\.py"] - repo: https://github.com/pycqa/flake8 rev: 7.0.0 hooks: From 595a05a1e6cae443f28819fdb08229d186f5a177 Mon Sep 17 00:00:00 2001 From: Sparky <59151395+Sparks29032@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:11:17 -0400 Subject: [PATCH 21/21] Correct exclude --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e70ab2d..4e6a136 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: rev: 24.4.2 hooks: - id: black - args: ["--exclude", "./doc/source/conf\.py"] + exclude: ./doc/source/conf\.py - repo: https://github.com/pycqa/flake8 rev: 7.0.0 hooks: