Skip to content

MNT: Update pre-commit hooks #24196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ repos:
- id: trailing-whitespace
exclude_types: [svg]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: [pydocstyle>5.1.0, flake8-docstrings>1.4.0, flake8-force]
args: ["--docstring-convention=all"]
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.2
hooks:
- id: codespell
files: ^.*\.(py|c|cpp|h|m|md|rst|yml)$
Expand Down
6 changes: 5 additions & 1 deletion ci/codespell-ignore-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ ba
cannotation
coo
curvelinear
dedented
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use in

dedented docstring; additional replacements can by given in *doc_sub*.

is reasonable so adding to ignore.

falsy
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falsy is how Python spells it, so adding.

flate
hax
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use in

fig, (vax, hax) = plt.subplots(1, 2, figsize=(12, 6))

for "horizontal axis" is reasonable, so added. However, if it would be preferable to make the example variables more explicit and verbose I can edit them instead.

hist
inh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use in

inl, inb, inw, inh = self._boxin.bounds

for "invalid height" is reasonable, so added.

inout
ment
nd
oly
sur
resizeable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use in

artist resizeable, moveable, highlightable, and selectable as desired

is a valid spelling, and so adding to ignore file.

sur is removed as added to the codespell dictionary in v2.2.0. c.f. codespell-project/codespell#2300

te
thisy
whis
Expand Down
35 changes: 18 additions & 17 deletions tools/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,21 @@
import fontforge


def log_namelist(nam, unicode):
if nam and isinstance(unicode, int):
print(f"0x{unicode:04X}", fontforge.nameFromUnicode(unicode), file=nam)
def log_namelist(name, unicode):
if name and isinstance(unicode, int):
print(f"0x{unicode:04X}", fontforge.nameeFromUnicode(unicode),
file=name)


def select_with_refs(font, unicode, newfont, pe=None, nam=None):
def select_with_refs(font, unicode, newfont, pe=None, name=None):
newfont.selection.select(('more', 'unicode'), unicode)
log_namelist(nam, unicode)
log_namelist(name, unicode)
if pe:
print(f"SelectMore({unicode})", file=pe)
try:
for ref in font[unicode].references:
newfont.selection.select(('more',), ref[0])
log_namelist(nam, ref[0])
log_namelist(name, ref[0])
if pe:
print(f'SelectMore("{ref[0]}")', file=pe)
except Exception:
Expand All @@ -60,11 +61,11 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
# 2010-12-06 DC To allow setting namelist filenames,
# change getopt.gnu_getopt from namelist to namelist=
# and invert comments on following 2 lines
# nam_fn = opts['--namelist']
nam_fn = f'{font_out}.nam'
nam = open(nam_fn, 'w')
# name_fn = opts['--namelist']
name_fn = f'{font_out}.name'
name = open(name_fn, 'w')
else:
nam = None
name = None
if '--script' in opts:
pe_fn = "/tmp/script.pe"
pe = open(pe_fn, 'w')
Expand All @@ -75,7 +76,7 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
print(f'Open("{font_in}")', file=pe)
extract_vert_to_script(font_in, pe)
for i in unicodes:
select_with_refs(font, i, font, pe, nam)
select_with_refs(font, i, font, pe, name)

addl_glyphs = []
if '--nmr' in opts:
Expand All @@ -86,9 +87,9 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
addl_glyphs.append('.notdef')
for glyph in addl_glyphs:
font.selection.select(('more',), glyph)
if nam:
if name:
print(f"0x{fontforge.unicodeFromName(glyph):0.4X}", glyph,
file=nam)
file=name)
if pe:
print(f'SelectMore("{glyph}")', file=pe)

Expand All @@ -112,7 +113,7 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
new.em = font.em
new.layers['Fore'].is_quadratic = font.layers['Fore'].is_quadratic
for i in unicodes:
select_with_refs(font, i, new, pe, nam)
select_with_refs(font, i, new, pe, name)
new.paste()
# This is a hack - it should have been taken care of above.
font.selection.select('space')
Expand Down Expand Up @@ -149,9 +150,9 @@ def subset_font_raw(font_in, font_out, unicodes, opts):
font.selection.select(glname)
font.cut()

if nam:
if name:
print("Writing NameList", end="")
nam.close()
name.close()

if pe:
print(f'Generate("{font_out}")', file=pe)
Expand All @@ -177,7 +178,7 @@ def subset_font(font_in, font_out, unicodes, opts):
if font_out != font_out_raw:
os.rename(font_out_raw, font_out)
# 2011-02-14 DC this needs to only happen with --namelist is used
# os.rename(font_out_raw + '.nam', font_out + '.nam')
# os.rename(font_out_raw + '.name', font_out + '.name')


def getsubset(subset, font_in):
Expand Down