Skip to content

Commit d67c192

Browse files
committed
style: fix pre-commit (codespell typos, black/isort, exclude vendored cxxtest and data)
1 parent e787297 commit d67c192

15 files changed

Lines changed: 94 additions & 55 deletions

‎.codespell/ignore_words.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ mater
66

77
;; Frobenius norm used in np.linalg.norm
88
fro
9+
10+
;; variable name for a pair type multiplicity in BaseDebyeSum.cpp
11+
multipl
12+
13+
;; custom scattering factor label used in TestScatteringFactorTable.hpp
14+
ccustom

‎.github/workflows/check-news-item.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Check for News
33
on:
44
pull_request_target:
55
branches:
6-
- main # GitHub does not evaluate expressions in trigger filters; edit this value if your base branch is not main
6+
- main # GitHub does not evaluate expressions in trigger filters; edit this value if your base branch is not main
77

88
jobs:
99
check-news-item:

‎.pre-commit-config.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ ci:
99
autoupdate_schedule: monthly
1010
skip: [no-commit-to-branch]
1111
submodules: false
12+
# Leave the vendored CxxTest SCons tool and the data tables untouched.
13+
exclude: |
14+
(?x)^(
15+
site_scons/site_tools/cxxtest\.py|
16+
.*\.(cif|dat)
17+
)$
1218
repos:
1319
- repo: https://github.com/pre-commit/pre-commit-hooks
1420
rev: v6.0.0

‎news/docs-migration.rst‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**Added:**
2+
3+
* Library overview from the old manual on the ``docs/`` index page.
4+
5+
**Changed:**
6+
7+
* Moved the Sphinx documentation from ``doc/manual/`` to the scikit-package ``docs/`` layout.
8+
* Read the documentation version from git tags through ``site_scons/libdiffpybuildutils.py``.
9+
10+
**Deprecated:**
11+
12+
* <news item>
13+
14+
**Removed:**
15+
16+
* Old ``doc/manual/`` Sphinx project.
17+
* Python ``automodule`` API page, which cannot document a C++ library.
18+
19+
**Fixed:**
20+
21+
* Pre-commit hooks now pass: fixed spelling in C++ comments, reformatted ``site_scons`` helpers, and excluded the vendored CxxTest tool and data tables.
22+
23+
**Security:**
24+
25+
* <news item>

‎site_scons/fallback_version.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env python
22

3-
'''
4-
Definition of FALLBACK_VERSION. Use it when git repository is
5-
not available for example, when building from git zip archive.
3+
"""Definition of FALLBACK_VERSION.
4+
5+
Use it when git repository is not available for example, when building
6+
from git zip archive.
67
78
Update FALLBACK_VERSION when tagging a new release.
8-
'''
9+
"""
910

10-
FALLBACK_VERSION = '1.4.0.post0'
11+
FALLBACK_VERSION = "1.4.0.post0"

‎site_scons/libdiffpybuildutils.py‎

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22

3-
'''Utility functions used by scons and sphinx for version extraction.
4-
'''
3+
"""Utility functions used by scons and sphinx for version extraction."""
54

65
import os
76
import re
@@ -21,79 +20,81 @@
2120

2221

2322
def gitinfo():
24-
'Extract dictionary of version data from git records.'
25-
from subprocess import Popen, PIPE
23+
"Extract dictionary of version data from git records."
24+
from subprocess import PIPE, Popen
25+
2626
global _cached_gitinfo
2727
if _cached_gitinfo is not None:
2828
return _cached_gitinfo
29-
nullfile = open(os.devnull, 'w')
30-
kw = dict(stdout=PIPE, stderr=nullfile, cwd=MYDIR,
31-
universal_newlines=True)
32-
proc = Popen(['git', 'describe', '--match=v[[:digit:]]*'], **kw)
29+
nullfile = open(os.devnull, "w")
30+
kw = dict(stdout=PIPE, stderr=nullfile, cwd=MYDIR, universal_newlines=True)
31+
proc = Popen(["git", "describe", "--match=v[[:digit:]]*"], **kw)
3332
desc = proc.stdout.read()
3433
if proc.wait():
3534
_cached_gitinfo = {}
3635
return gitinfo()
37-
proc = Popen(['git', 'log', '-1', '--format=%H %ci'], **kw)
36+
proc = Popen(["git", "log", "-1", "--format=%H %ci"], **kw)
3837
glog = proc.stdout.read()
39-
words = desc.strip().split('-')
40-
vtag = words[0].lstrip('v')
41-
vnum = int((words[1:2] or ['0'])[0])
38+
words = desc.strip().split("-")
39+
vtag = words[0].lstrip("v")
40+
vnum = int((words[1:2] or ["0"])[0])
4241
rv = {}
43-
rv['commit'], rv['date'] = glog.strip().split(None, 1)
44-
rv['patchnumber'] = vnum
45-
rv['version'] = vtag
42+
rv["commit"], rv["date"] = glog.strip().split(None, 1)
43+
rv["patchnumber"] = vnum
44+
rv["version"] = vtag
4645
if vnum:
47-
rv['version'] += '.post' + str(vnum)
46+
rv["version"] += ".post" + str(vnum)
4847
_cached_gitinfo = rv
4948
return gitinfo()
5049

50+
5151
_cached_gitinfo = None
5252

5353

5454
def getversion():
5555
"""Extract version from gitinfo and/or gitarchive.cfg file.
5656
57-
Process gitinfo first and make sure it matches FALLBACK_VERSION
58-
in gitarchive.cfg. Use expanded data from gitarchive.cfg when
59-
these sources are from git archive bundle.
57+
Process gitinfo first and make sure it matches FALLBACK_VERSION in
58+
gitarchive.cfg. Use expanded data from gitarchive.cfg when these
59+
sources are from git archive bundle.
6060
"""
6161
from fallback_version import FALLBACK_VERSION
62-
gitarchivecfgfile = os.path.join(MYDIR, 'gitarchive.cfg')
62+
63+
gitarchivecfgfile = os.path.join(MYDIR, "gitarchive.cfg")
6364
assert os.path.isfile(gitarchivecfgfile)
6465
with open(gitarchivecfgfile) as fp:
6566
gacontent = fp.read()
66-
gaitems = re.findall(r'^(\w+) *= *(\S.*?)\s*$', gacontent, re.M)
67+
gaitems = re.findall(r"^(\w+) *= *(\S.*?)\s*$", gacontent, re.M)
6768
ga = dict(gaitems)
6869
gi = gitinfo()
6970
rv = {}
7071
if gi:
7172
afb = FALLBACK_VERSION
72-
gfb = gi['version'].split('.post')[0] + '.post0'
73+
gfb = gi["version"].split(".post")[0] + ".post0"
7374
if gfb != afb:
7475
raise RuntimeError(EMSG_BAD_FALLBACK_VERSION.format(afb, gfb))
7576
rv.update(gi)
7677
else:
7778
# Not a git repository. Require that gitarchive.cfg is expanded.
78-
if '$Format:' in ga['commit']:
79+
if "$Format:" in ga["commit"]:
7980
raise RuntimeError(EMSG_GIT_MISSING)
80-
rv['commit'] = ga['commit']
81-
rv['date'] = ga['date']
81+
rv["commit"] = ga["commit"]
82+
rv["date"] = ga["date"]
8283
# First assume we have an undetermined post-release. Keep version
8384
# suffix as ".post0", but set patchnumber to ensure we are post
8485
# FALLBACK_VERSION.
85-
rv['version'] = FALLBACK_VERSION
86-
rv['patchnumber'] = 1
86+
rv["version"] = FALLBACK_VERSION
87+
rv["patchnumber"] = 1
8788
# If we are at version tag turn this to regular release.
88-
mx = re.search(r'\btag: v(\d[^,]*)', ga['refnames'])
89+
mx = re.search(r"\btag: v(\d[^,]*)", ga["refnames"])
8990
if mx:
90-
rv['version'] = mx.group(1)
91-
rv['patchnumber'] = 0
91+
rv["version"] = mx.group(1)
92+
rv["patchnumber"] = 0
9293
# rv['version'] is resolved, let's parse its subfields.
93-
vbase = rv['version'].split('.post')[0]
94-
mx = re.match(r'^(\d+)\.(\d+)(?:\.(\d+))?((?:[ab]|rc)\d*)?', vbase)
95-
rv['major'] = int(mx.group(1))
96-
rv['minor'] = int(mx.group(2))
97-
rv['micro'] = int(mx.group(3) or 0)
98-
rv['prerelease'] = mx.group(4)
94+
vbase = rv["version"].split(".post")[0]
95+
mx = re.match(r"^(\d+)\.(\d+)(?:\.(\d+))?((?:[ab]|rc)\d*)?", vbase)
96+
rv["major"] = int(mx.group(1))
97+
rv["minor"] = int(mx.group(2))
98+
rv["micro"] = int(mx.group(3) or 0)
99+
rv["prerelease"] = mx.group(4)
99100
return rv

‎src/diffpy/HasClassRegistry.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* functions that produce derived classes. To be used as a base for a
1717
* specific class branch. For a proper function, the HasClassRegistry
1818
* template must be instantiated in just one cpp file that includes the
19-
* implementatios in HasClassRegistry.ipp.
19+
* implementations in HasClassRegistry.ipp.
2020
*
2121
* A Base class with registry should be declared as
2222
* class Base : public HasClassRegistry<Base>
@@ -62,7 +62,7 @@ class HasClassRegistry
6262

6363
/// Clear registration of the specified type under its standard name
6464
/// or any alias. Return the number of unset names and aliases or
65-
/// 0 if the specifed string type was not registered.
65+
/// 0 if the specified string type was not registered.
6666
static int deregisterType(const std::string& tp);
6767

6868
/// Create new instance of a specified string type.

‎src/diffpy/srreal/PairQuantity.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void PairQuantity::updateMaskData()
448448
// rebuild minvertpairmask according to mtypemask
449449
minvertpairmask.clear();
450450
TypeMaskStorage::const_iterator tpmsk;
451-
// build a list of type masks with all-masks at the begining
451+
// build a list of type masks with all-masks at the beginning
452452
list< pair<string,string> > orderedpairs;
453453
for (tpmsk = mtypemask.begin(); tpmsk != mtypemask.end(); ++tpmsk)
454454
{

‎src/diffpy/srreal/PeakProfile.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
******************************************************************************
1414
*
1515
* class PeakProfile -- base class for calculation of peak profiles.
16-
* When possible total integrated area of the profile should eqaul 1.
16+
* When possible total integrated area of the profile should equal 1.
1717
* The operator()(x, fwhm) returns amplitude of a zero-centered profile.
1818
* Methods xboundlo(fwhm), xboundhi(fwhm) return low and high x-boundaries,
1919
* where amplitude relative to the maximum becomes smaller than precision

‎src/diffpy/srreal/PointsInSphere.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* classes PointsInSphere, ReflectionsInQminQmax, ReflectionsInDmaxDmin
1616
*
17-
* Comments: sequencers for lattice points insided 3D sphere
17+
* Comments: sequencers for lattice points inside 3D sphere
1818
*
1919
*****************************************************************************/
2020

@@ -117,7 +117,7 @@ void PointsInSphere::rewind()
117117
mHalfSpan = Rmax()*latpar.ar;
118118
hi_m = int(ceil(mHalfSpan));
119119
this->_m = -hi_m;
120-
// make indices n, o invalid, reset the neares point
120+
// make indices n, o invalid, reset the nearest point
121121
this->_n = hi_n = 0;
122122
this->_o = hi_o = outside_o = 0;
123123
n0plane = o0plane = o0line = 0.0;

0 commit comments

Comments
 (0)