Skip to content

Commit bef2e16

Browse files
dstansbynormanrz
andauthored
Add ruff pre-commit hooks (#537)
* Add ruff pre-commit hook * Add ruff-format pre-commit hook * Trigger Build * trigger ci --------- Co-authored-by: Norman Rzepka <[email protected]>
1 parent 485224f commit bef2e16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+644
-547
lines changed

.flake8

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

.github/workflows/ci.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ jobs:
7777
conda activate env
7878
python -m pip list
7979
80-
- name: Flake8
81-
shell: "bash -l {0}"
82-
run: |
83-
conda activate env
84-
flake8
85-
8680
- name: Run tests
8781
shell: "bash -l {0}"
8882
run: |

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ci:
2+
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autofix_commit_msg: "style: pre-commit fixes"
4+
autofix_prs: false
5+
default_stages: [commit, push]
6+
default_language_version:
7+
python: python3
8+
repos:
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: 'v0.4.9'
11+
hooks:
12+
- id: ruff
13+
args: ["--fix", "--show-fixes"]
14+
- id: ruff-format

docs/conf.py

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import sys
1717
import os
1818
from unittest.mock import Mock as MagicMock
19+
import numcodecs
20+
1921

2022
class Mock(MagicMock):
2123
@classmethod
@@ -36,7 +38,7 @@ def __getattr__(cls, name):
3638
# -- General configuration ------------------------------------------------
3739

3840
# If your documentation needs a minimal Sphinx version, state it here.
39-
#needs_sphinx = '1.0'
41+
# needs_sphinx = '1.0'
4042

4143
# Add any Sphinx extension module names here, as strings. They can be
4244
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -62,7 +64,7 @@ def __getattr__(cls, name):
6264
source_suffix = '.rst'
6365

6466
# The encoding of source files.
65-
#source_encoding = 'utf-8-sig'
67+
# source_encoding = 'utf-8-sig'
6668

6769
# The main toctree document.
6870
main_doc = 'index'
@@ -77,7 +79,6 @@ def __getattr__(cls, name):
7779
# built documents.
7880
#
7981
# The short X.Y version.
80-
import numcodecs
8182
version = numcodecs.__version__
8283
# The full version, including alpha/beta/rc tags.
8384
release = numcodecs.__version__
@@ -91,9 +92,9 @@ def __getattr__(cls, name):
9192

9293
# There are two options for replacing |today|: either, you set today to some
9394
# non-false value, then it is used:
94-
#today = ''
95+
# today = ''
9596
# Else, today_fmt is used as the format for a strftime call.
96-
#today_fmt = '%B %d, %Y'
97+
# today_fmt = '%B %d, %Y'
9798

9899
# List of patterns, relative to source directory, that match files and
99100
# directories to ignore when looking for source files.
@@ -102,27 +103,27 @@ def __getattr__(cls, name):
102103

103104
# The reST default role (used for this markup: `text`) to use for all
104105
# documents.
105-
#default_role = None
106+
# default_role = None
106107

107108
# If true, '()' will be appended to :func: etc. cross-reference text.
108-
#add_function_parentheses = True
109+
# add_function_parentheses = True
109110

110111
# If true, the current module name will be prepended to all description
111112
# unit titles (such as .. function::).
112-
#add_module_names = True
113+
# add_module_names = True
113114

114115
# If true, sectionauthor and moduleauthor directives will be shown in the
115116
# output. They are ignored by default.
116-
#show_authors = False
117+
# show_authors = False
117118

118119
# The name of the Pygments (syntax highlighting) style to use.
119120
pygments_style = 'sphinx'
120121

121122
# A list of ignored prefixes for module index sorting.
122-
#modindex_common_prefix = []
123+
# modindex_common_prefix = []
123124

124125
# If true, keep warnings as "system message" paragraphs in the built documents.
125-
#keep_warnings = False
126+
# keep_warnings = False
126127

127128
# If true, `todo` and `todoList` produce output, else they produce nothing.
128129
todo_include_todos = False
@@ -137,26 +138,26 @@ def __getattr__(cls, name):
137138
# Theme options are theme-specific and customize the look and feel of a theme
138139
# further. For a list of options available for each theme, see the
139140
# documentation.
140-
#html_theme_options = {}
141+
# html_theme_options = {}
141142

142143
# Add any paths that contain custom themes here, relative to this directory.
143-
#html_theme_path = []
144+
# html_theme_path = []
144145

145146
# The name for this set of Sphinx documents.
146147
# "<project> v<release> documentation" by default.
147-
#html_title = 'numcodecs v@@'
148+
# html_title = 'numcodecs v@@'
148149

149150
# A shorter title for the navigation bar. Default is the same as html_title.
150-
#html_short_title = None
151+
# html_short_title = None
151152

152153
# The name of an image file (relative to this directory) to place at the top
153154
# of the sidebar.
154-
#html_logo = None
155+
# html_logo = None
155156

156157
# The name of an image file (relative to this directory) to use as a favicon of
157158
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
158159
# pixels large.
159-
#html_favicon = None
160+
# html_favicon = None
160161

161162
# Add any paths that contain custom static files (such as style sheets) here,
162163
# relative to this directory. They are copied after the builtin static files,
@@ -166,124 +167,117 @@ def __getattr__(cls, name):
166167
# Add any extra paths that contain custom files (such as robots.txt or
167168
# .htaccess) here, relative to this directory. These files are copied
168169
# directly to the root of the documentation.
169-
#html_extra_path = []
170+
# html_extra_path = []
170171

171172
# If not None, a 'Last updated on:' timestamp is inserted at every page
172173
# bottom, using the given strftime format.
173174
# The empty string is equivalent to '%b %d, %Y'.
174-
#html_last_updated_fmt = None
175+
# html_last_updated_fmt = None
175176

176177
# If true, SmartyPants will be used to convert quotes and dashes to
177178
# typographically correct entities.
178-
#html_use_smartypants = True
179+
# html_use_smartypants = True
179180

180181
# Custom sidebar templates, maps document names to template names.
181-
#html_sidebars = {}
182+
# html_sidebars = {}
182183

183184
# Additional templates that should be rendered to pages, maps page names to
184185
# template names.
185-
#html_additional_pages = {}
186+
# html_additional_pages = {}
186187

187188
# If false, no module index is generated.
188-
#html_domain_indices = True
189+
# html_domain_indices = True
189190

190191
# If false, no index is generated.
191-
#html_use_index = True
192+
# html_use_index = True
192193

193194
# If true, the index is split into individual pages for each letter.
194-
#html_split_index = False
195+
# html_split_index = False
195196

196197
# If true, links to the reST sources are added to the pages.
197-
#html_show_sourcelink = True
198+
# html_show_sourcelink = True
198199

199200
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
200-
#html_show_sphinx = True
201+
# html_show_sphinx = True
201202

202203
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
203-
#html_show_copyright = True
204+
# html_show_copyright = True
204205

205206
# If true, an OpenSearch description file will be output, and all pages will
206207
# contain a <link> tag referring to it. The value of this option must be the
207208
# base URL from which the finished HTML is served.
208-
#html_use_opensearch = ''
209+
# html_use_opensearch = ''
209210

210211
# This is the file name suffix for HTML files (e.g. ".xhtml").
211-
#html_file_suffix = None
212+
# html_file_suffix = None
212213

213214
# Language to be used for generating the HTML full-text search index.
214215
# Sphinx supports the following languages:
215216
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
216217
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh'
217-
#html_search_language = 'en'
218+
# html_search_language = 'en'
218219

219220
# A dictionary with options for the search language support, empty by default.
220221
# 'ja' uses this config value.
221222
# 'zh' user can custom change `jieba` dictionary path.
222-
#html_search_options = {'type': 'default'}
223+
# html_search_options = {'type': 'default'}
223224

224225
# The name of a javascript file (relative to the configuration directory) that
225226
# implements a search results scorer. If empty, the default will be used.
226-
#html_search_scorer = 'scorer.js'
227+
# html_search_scorer = 'scorer.js'
227228

228229
# Output file base name for HTML help builder.
229230
htmlhelp_basename = 'numcodecsdoc'
230231

231232
# -- Options for LaTeX output ---------------------------------------------
232233

233234
latex_elements = {
234-
# The paper size ('letterpaper' or 'a4paper').
235-
#'papersize': 'letterpaper',
236-
237-
# The font size ('10pt', '11pt' or '12pt').
238-
#'pointsize': '10pt',
239-
240-
# Additional stuff for the LaTeX preamble.
241-
#'preamble': '',
242-
243-
# Latex figure (float) alignment
244-
#'figure_align': 'htbp',
235+
# The paper size ('letterpaper' or 'a4paper').
236+
#'papersize': 'letterpaper',
237+
# The font size ('10pt', '11pt' or '12pt').
238+
#'pointsize': '10pt',
239+
# Additional stuff for the LaTeX preamble.
240+
#'preamble': '',
241+
# Latex figure (float) alignment
242+
#'figure_align': 'htbp',
245243
}
246244

247245
# Grouping the document tree into LaTeX files. List of tuples
248246
# (source start file, target name, title,
249247
# author, documentclass [howto, manual, or own class]).
250248
latex_documents = [
251-
(main_doc, 'numcodecs.tex', 'numcodecs Documentation',
252-
'Alistair Miles', 'manual'),
249+
(main_doc, 'numcodecs.tex', 'numcodecs Documentation', 'Alistair Miles', 'manual'),
253250
]
254251

255252
# The name of an image file (relative to this directory) to place at the top of
256253
# the title page.
257-
#latex_logo = None
254+
# latex_logo = None
258255

259256
# For "manual" documents, if this is true, then toplevel headings are parts,
260257
# not chapters.
261-
#latex_use_parts = False
258+
# latex_use_parts = False
262259

263260
# If true, show page references after internal links.
264-
#latex_show_pagerefs = False
261+
# latex_show_pagerefs = False
265262

266263
# If true, show URL addresses after external links.
267-
#latex_show_urls = False
264+
# latex_show_urls = False
268265

269266
# Documents to append as an appendix to all manuals.
270-
#latex_appendices = []
267+
# latex_appendices = []
271268

272269
# If false, no module index is generated.
273-
#latex_domain_indices = True
270+
# latex_domain_indices = True
274271

275272

276273
# -- Options for manual page output ---------------------------------------
277274

278275
# One entry per manual page. List of tuples
279276
# (source start file, name, description, authors, manual section).
280-
man_pages = [
281-
(main_doc, 'numcodecs', 'numcodecs Documentation',
282-
[author], 1)
283-
]
277+
man_pages = [(main_doc, 'numcodecs', 'numcodecs Documentation', [author], 1)]
284278

285279
# If true, show URL addresses after external links.
286-
#man_show_urls = False
280+
# man_show_urls = False
287281

288282

289283
# -- Options for Texinfo output -------------------------------------------
@@ -292,22 +286,28 @@ def __getattr__(cls, name):
292286
# (source start file, target name, title, author,
293287
# dir menu entry, description, category)
294288
texinfo_documents = [
295-
(main_doc, 'numcodecs', 'numcodecs Documentation',
296-
author, 'numcodecs', 'One line description of project.',
297-
'Miscellaneous'),
289+
(
290+
main_doc,
291+
'numcodecs',
292+
'numcodecs Documentation',
293+
author,
294+
'numcodecs',
295+
'One line description of project.',
296+
'Miscellaneous',
297+
),
298298
]
299299

300300
# Documents to append as an appendix to all manuals.
301-
#texinfo_appendices = []
301+
# texinfo_appendices = []
302302

303303
# If false, no module index is generated.
304-
#texinfo_domain_indices = True
304+
# texinfo_domain_indices = True
305305

306306
# How to display URL addresses: 'footnote', 'no', or 'inline'.
307-
#texinfo_show_urls = 'footnote'
307+
# texinfo_show_urls = 'footnote'
308308

309309
# If true, do not generate a @detailmenu in the "Top" node's menu.
310-
#texinfo_no_detailmenu = False
310+
# texinfo_no_detailmenu = False
311311

312312

313313
# Example configuration for intersphinx: refer to the Python standard library.

docs/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ You will need your own fork to work on the code. Go to the link above and hit
7676
the "Fork" button. Then clone your fork to your local machine::
7777

7878
$ git clone --recursive [email protected]:your-user-name/numcodecs.git # with ``ssh``
79-
79+
8080
or::
8181

8282
$ git clone --recursive https://github.com/your-user-name/numcodecs.git # with ``https``
@@ -158,7 +158,7 @@ All code must conform to the PEP8 standard. Regarding line length, lines up to 1
158158
characters are allowed, although please try to keep under 90 wherever possible.
159159
Conformance can be checked by running::
160160

161-
$ flake8
161+
$ pre-commit run ruff
162162

163163
Test coverage
164164
~~~~~~~~~~~~~

0 commit comments

Comments
 (0)