Skip to content

Commit 6c7f548

Browse files
committed
feat: Run Black via pre-commit
- Remove the need for the `scripts/format` file - Format two previously not included files
1 parent 46fbaa7 commit 6c7f548

File tree

7 files changed

+66
-74
lines changed

7 files changed

+66
-74
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
**PR Checklist:**
88

9-
- [ ] Code is formatted (run `scripts/format`)
9+
- [ ] Code is formatted (run `pre-commit run --all-files`)
1010
- [ ] Tests pass (run `scripts/test`)
1111
- [ ] This PR maintains or improves overall codebase code coverage.
1212
- [ ] Changes are added to the [CHANGELOG](https://github.com/stac-utils/pystac/blob/develop/CHANGELOG.md). See [the docs](https://pystac.readthedocs.io/en/latest/contributing.html#changelog) for information about adding to the changelog.

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Configuration file for pre-commit (https://pre-commit.com/).
2+
# Please run `pre-commit run --all-files` when adding or changing entries.
3+
4+
repos:
5+
- repo: local
6+
hooks:
7+
- id: black
8+
name: black
9+
entry: black
10+
language: system
11+
stages: [commit]
12+
types: [python]

docs/conf.py

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@
1717
import subprocess
1818
from typing import Any, Dict
1919

20-
sys.path.insert(0, os.path.abspath('.'))
21-
sys.path.insert(0, os.path.abspath('../'))
20+
sys.path.insert(0, os.path.abspath("."))
21+
sys.path.insert(0, os.path.abspath("../"))
2222
from pystac.version import __version__, STACVersion
2323

24-
git_branch = subprocess.check_output(['git',
25-
'rev-parse',
26-
'--abbrev-ref',
27-
'HEAD']) \
28-
.decode("utf-8") \
29-
.strip()
24+
git_branch = (
25+
subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
26+
.decode("utf-8")
27+
.strip()
28+
)
3029

3130
# -- Project information -----------------------------------------------------
3231

33-
project = 'pystac'
34-
copyright = '2019, Azavea'
35-
author = 'stac-utils'
32+
project = "pystac"
33+
copyright = "2019, Azavea"
34+
author = "stac-utils"
3635

3736
# The short X.Y version
3837
version = __version__
@@ -50,35 +49,41 @@
5049
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
5150
# ones.
5251
extensions = [
53-
'sphinx.ext.autodoc',
54-
'sphinx.ext.viewcode',
55-
'sphinx.ext.intersphinx',
56-
'sphinx.ext.napoleon',
57-
'sphinx.ext.githubpages',
58-
'sphinx.ext.extlinks',
59-
'sphinxcontrib.fulltoc',
60-
'nbsphinx'
52+
"sphinx.ext.autodoc",
53+
"sphinx.ext.viewcode",
54+
"sphinx.ext.intersphinx",
55+
"sphinx.ext.napoleon",
56+
"sphinx.ext.githubpages",
57+
"sphinx.ext.extlinks",
58+
"sphinxcontrib.fulltoc",
59+
"nbsphinx",
6160
]
6261

6362
extlinks = {
64-
'tutorial': ('https://github.com/stac-utils/pystac/'
65-
'tree/{}/docs/tutorials/%s'.format(git_branch), 'tutorial'),
66-
'stac-spec': ('https://github.com/radiantearth/stac-spec/tree/'
67-
'v{}/%s'.format(STACVersion.DEFAULT_STAC_VERSION), 'path'),
68-
'stac-ext': ('https://github.com/stac-extensions/%s', '%s extension')
63+
"tutorial": (
64+
"https://github.com/stac-utils/pystac/"
65+
"tree/{}/docs/tutorials/%s".format(git_branch),
66+
"tutorial",
67+
),
68+
"stac-spec": (
69+
"https://github.com/radiantearth/stac-spec/tree/"
70+
"v{}/%s".format(STACVersion.DEFAULT_STAC_VERSION),
71+
"path",
72+
),
73+
"stac-ext": ("https://github.com/stac-extensions/%s", "%s extension"),
6974
}
7075

7176
# Add any paths that contain templates here, relative to this directory.
72-
templates_path = ['_templates']
77+
templates_path = ["_templates"]
7378

7479
# The suffix(es) of source filenames.
7580
# You can specify multiple suffix as a list of string:
7681
#
7782
# source_suffix = ['.rst', '.md']
78-
source_suffix = '.rst'
83+
source_suffix = ".rst"
7984

8085
# The master toctree document.
81-
master_doc = 'index'
86+
master_doc = "index"
8287

8388
# The language for content autogenerated by Sphinx. Refer to documentation
8489
# for a list of supported languages.
@@ -90,7 +95,7 @@
9095
# List of patterns, relative to source directory, that match files and
9196
# directories to ignore when looking for source files.
9297
# This pattern also affects html_static_path and html_extra_path.
93-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
98+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
9499

95100
# The name of the Pygments (syntax highlighting) style to use.
96101
pygments_style = None
@@ -101,7 +106,7 @@
101106
# The theme to use for HTML and HTML Help pages. See the documentation for
102107
# a list of builtin themes.
103108
#
104-
html_theme = 'alabaster'
109+
html_theme = "alabaster"
105110

106111
# Theme options are theme-specific and customize the look and feel of a theme
107112
# further. For a list of options available for each theme, see the
@@ -119,7 +124,7 @@
119124
# Add any paths that contain custom static files (such as style sheets) here,
120125
# relative to this directory. They are copied after the builtin static files,
121126
# so a file named "default.css" will overwrite the builtin "default.css".
122-
#html_static_path = ['_static']
127+
# html_static_path = ['_static']
123128

124129
# Custom sidebar templates, must be a dictionary that maps document names
125130
# to template names.
@@ -135,7 +140,7 @@
135140
# -- Options for HTMLHelp output ---------------------------------------------
136141

137142
# Output file base name for HTML help builder.
138-
htmlhelp_basename = 'pystacdoc'
143+
htmlhelp_basename = "pystacdoc"
139144

140145

141146
# -- Options for LaTeX output ------------------------------------------------
@@ -144,15 +149,12 @@
144149
# The paper size ('letterpaper' or 'a4paper').
145150
#
146151
# 'papersize': 'letterpaper',
147-
148152
# The font size ('10pt', '11pt' or '12pt').
149153
#
150154
# 'pointsize': '10pt',
151-
152155
# Additional stuff for the LaTeX preamble.
153156
#
154157
# 'preamble': '',
155-
156158
# Latex figure (float) alignment
157159
#
158160
# 'figure_align': 'htbp',
@@ -162,19 +164,15 @@
162164
# (source start file, target name, title,
163165
# author, documentclass [howto, manual, or own class]).
164166
latex_documents = [
165-
(master_doc, 'pystac.tex', 'pystac Documentation',
166-
'stac-utils', 'manual'),
167+
(master_doc, "pystac.tex", "pystac Documentation", "stac-utils", "manual"),
167168
]
168169

169170

170171
# -- Options for manual page output ------------------------------------------
171172

172173
# One entry per manual page. List of tuples
173174
# (source start file, name, description, authors, manual section).
174-
man_pages = [
175-
(master_doc, 'pystac', 'pystac Documentation',
176-
[author], 1)
177-
]
175+
man_pages = [(master_doc, "pystac", "pystac Documentation", [author], 1)]
178176

179177

180178
# -- Options for Texinfo output ----------------------------------------------
@@ -183,9 +181,15 @@
183181
# (source start file, target name, title, author,
184182
# dir menu entry, description, category)
185183
texinfo_documents = [
186-
(master_doc, 'pystac', 'pystac Documentation',
187-
author, 'pystac', 'Python library for SpatioTemporal Asset Catalogs (STAC).',
188-
'Miscellaneous'),
184+
(
185+
master_doc,
186+
"pystac",
187+
"pystac Documentation",
188+
author,
189+
"pystac",
190+
"Python library for SpatioTemporal Asset Catalogs (STAC).",
191+
"Miscellaneous",
192+
),
189193
]
190194

191195

@@ -204,11 +208,11 @@
204208
# epub_uid = ''
205209

206210
# A list of files that should not be packed into the epub file.
207-
epub_exclude_files = ['search.html']
211+
epub_exclude_files = ["search.html"]
208212

209213

210214
# -- Extension configuration -------------------------------------------------
211215

212216
intersphinx_mapping = {
213-
'python': ('https://docs.python.org/3', None),
217+
"python": ("https://docs.python.org/3", None),
214218
}

docs/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To format code:
5858

5959
.. code-block:: bash
6060
61-
> ./scripts/format
61+
> pre-commit run --all-files
6262
6363
We also use `doc8 <https://github.com/pycqa/doc8>`__ for style checking on RST files in
6464
the docs.

requirements-test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ doc8==0.8.1
1111
types-python-dateutil==0.1.3
1212
types-orjson==0.1.0
1313

14+
pre-commit==2.13.0
15+
1416
# optional dependencies
1517
orjson==3.5.3

scripts/format

Lines changed: 0 additions & 24 deletions
This file was deleted.

scripts/lint

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ echo
1818
echo " -- CHECKING FORMAT WITH BLACK --"
1919
echo
2020

21-
black --check pystac
22-
black --check tests
23-
black --check setup.py
21+
pre-commit run --all-files
2422

2523
echo
2624
echo " -- CHECKING SPELLING WITH CODESPELL --"

0 commit comments

Comments
 (0)