Skip to content
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: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ repos:
name: Run Ruff (lint) on Tools/build/
args: [--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]
files: ^Tools/build/
- id: ruff
name: Run Ruff (lint) on Tools/i18n/
args: [--exit-non-zero-on-fix, --config=Tools/i18n/.ruff.toml]
files: ^Tools/i18n/
- id: ruff
name: Run Ruff (lint) on Argument Clinic
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/descriptor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ Here are three practical data validation utilities:

def validate(self, value):
if not isinstance(value, str):
raise TypeError(f'Expected {value!r} to be an str')
raise TypeError(f'Expected {value!r} to be a str')
if self.minsize is not None and len(value) < self.minsize:
raise ValueError(
f'Expected {value!r} to be no smaller than {self.minsize!r}'
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_io/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
from test.support import load_package_tests

def load_tests(*args):
return load_package_tests(os.path.dirname(__file__), *args)
4 changes: 4 additions & 0 deletions Lib/test/test_io/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import load_tests
import unittest

unittest.main()
2 changes: 1 addition & 1 deletion Lib/test/test_io.py → Lib/test/test_io/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * test_memoryio - tests BytesIO and StringIO
# * test_fileio - tests FileIO
# * test_file - tests the file interface
# * test_io - tests everything else in the io module
# * test_io.test_general - tests everything else in the io module
# * test_univnewlines - tests universal newline support
# * test_largefile - tests operations on a file greater than 2**32 bytes
# (only enabled with -ulargefile)
Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,7 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_importlib/source \
test/test_inspect \
test/test_interpreters \
test/test_io \
test/test_json \
test/test_module \
test/test_multiprocessing_fork \
Expand Down
10 changes: 10 additions & 0 deletions Tools/i18n/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extend = "../../.ruff.toml" # Inherit the project-wide settings

target-version = "py313"

[lint]
select = [
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
]
14 changes: 7 additions & 7 deletions Tools/i18n/makelocalealias.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
import locale
import sys

_locale = locale

# Location of the X11 alias file.
Expand Down Expand Up @@ -100,16 +101,15 @@ def parse_glibc_supported(filename):
def pprint(data):
items = sorted(data.items())
for k, v in items:
print(' %-40s%a,' % ('%a:' % k, v))
print(f" {k!a:<40}{v!a},")

def print_differences(data, olddata):
items = sorted(olddata.items())
for k, v in items:
if k not in data:
print('# removed %a' % k)
print(f'# removed {k!a}')
elif olddata[k] != data[k]:
print('# updated %a -> %a to %a' % \
(k, olddata[k], data[k]))
print(f'# updated {k!a} -> {olddata[k]!a} to {data[k]!a}')
# Additions are not mentioned

def optimize(data):
Expand All @@ -132,7 +132,7 @@ def check(data):
errors = 0
for k, v in data.items():
if locale.normalize(k) != v:
print('ERROR: %a -> %a != %a' % (k, locale.normalize(k), v),
print(f'ERROR: {k!a} -> {locale.normalize(k)!a} != {v!a}',
file=sys.stderr)
errors += 1
return errors
Expand All @@ -142,10 +142,10 @@ def check(data):
parser = argparse.ArgumentParser()
parser.add_argument('--locale-alias', default=LOCALE_ALIAS,
help='location of the X11 alias file '
'(default: %a)' % LOCALE_ALIAS)
f'(default: {LOCALE_ALIAS})')
parser.add_argument('--glibc-supported', default=SUPPORTED,
help='location of the glibc SUPPORTED locales file '
'(default: %a)' % SUPPORTED)
f'(default: {SUPPORTED})')
args = parser.parse_args()

data = locale.locale_alias.copy()
Expand Down
22 changes: 11 additions & 11 deletions Tools/i18n/msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
Display version information and exit.
"""

import os
import sys
import array
import ast
import codecs
import getopt
import os
import struct
import array
import sys
from email.parser import HeaderParser
import codecs

__version__ = "1.2"

Expand Down Expand Up @@ -113,7 +113,7 @@ def make(filename, outfile):
try:
with open(infile, 'rb') as f:
lines = f.readlines()
except IOError as msg:
except OSError as msg:
print(msg, file=sys.stderr)
sys.exit(1)

Expand All @@ -126,6 +126,7 @@ def make(filename, outfile):
sys.exit(1)

section = msgctxt = None
msgid = msgstr = b''
fuzzy = 0

# Start off assuming Latin-1, so everything decodes without failure,
Expand Down Expand Up @@ -177,7 +178,7 @@ def make(filename, outfile):
# This is a message with plural forms
elif l.startswith('msgid_plural'):
if section != ID:
print('msgid_plural not preceded by msgid on %s:%d' % (infile, lno),
print(f'msgid_plural not preceded by msgid on {infile}:{lno}',
file=sys.stderr)
sys.exit(1)
l = l[12:]
Expand All @@ -188,15 +189,15 @@ def make(filename, outfile):
section = STR
if l.startswith('msgstr['):
if not is_plural:
print('plural without msgid_plural on %s:%d' % (infile, lno),
print(f'plural without msgid_plural on {infile}:{lno}',
file=sys.stderr)
sys.exit(1)
l = l.split(']', 1)[1]
if msgstr:
msgstr += b'\0' # Separator of the various plural forms
else:
if is_plural:
print('indexed msgstr required for plural on %s:%d' % (infile, lno),
print(f'indexed msgstr required for plural on {infile}:{lno}',
file=sys.stderr)
sys.exit(1)
l = l[6:]
Expand All @@ -212,8 +213,7 @@ def make(filename, outfile):
elif section == STR:
msgstr += l.encode(encoding)
else:
print('Syntax error on %s:%d' % (infile, lno), \
'before:', file=sys.stderr)
print(f'Syntax error on {infile}:{lno} before:', file=sys.stderr)
print(l, file=sys.stderr)
sys.exit(1)
# Add last entry
Expand All @@ -226,7 +226,7 @@ def make(filename, outfile):
try:
with open(outfile,"wb") as f:
f.write(output)
except IOError as msg:
except OSError as msg:
print(msg, file=sys.stderr)


Expand Down
4 changes: 2 additions & 2 deletions Tools/i18n/pygettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def make_escapes(pass_nonascii):
escape = escape_ascii
else:
escape = escape_nonascii
escapes = [r"\%03o" % i for i in range(256)]
escapes = [fr"\{i:03o}" for i in range(256)]
for i in range(32, 127):
escapes[i] = chr(i)
escapes[ord('\\')] = r'\\'
Expand Down Expand Up @@ -796,7 +796,7 @@ class Options:
try:
with open(options.excludefilename) as fp:
options.toexclude = fp.readlines()
except IOError:
except OSError:
print(f"Can't read --exclude-file: {options.excludefilename}",
file=sys.stderr)
sys.exit(1)
Expand Down
Loading