Skip to content

Commit bfd72c8

Browse files
authored
Merge branch 'main' into typing-errors
2 parents f879aaa + 4784a52 commit bfd72c8

22 files changed

+51
-69
lines changed

.github/workflows/wheel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
submodules: true
2828

29-
- uses: pypa/cibuildwheel@v2.19.2
29+
- uses: pypa/cibuildwheel@v2.20.0
3030

3131
- uses: actions/upload-artifact@v4
3232
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default_language_version:
77
python: python3
88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: 'v0.5.2'
10+
rev: 'v0.6.1'
1111
hooks:
1212
- id: ruff
1313
args: ["--fix", "--show-fixes"]

docs/release.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Fix
2121

2222
Maintenance
2323
~~~~~~~~~~~
24+
* Change format() and old string formatting to f-strings.
25+
By :user:`Dimitri Papadopoulos Orfanos <DimitriPapadopoulos>`, :issue:`439`.
2426

2527
* Remove pin on Sphinx
2628
By :user:`Elliott Sales de Andrade <QuLogic>`, :issue:`552`.

notebooks/benchmark_vlen.ipynb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"source": [
2727
"import numpy as np\n",
2828
"import numcodecs\n",
29+
"\n",
2930
"numcodecs.__version__"
3031
]
3132
},
@@ -67,6 +68,7 @@
6768
"outputs": [],
6869
"source": [
6970
"from numcodecs.tests.common import greetings\n",
71+
"\n",
7072
"msgpack_codec = numcodecs.MsgPack()\n",
7173
"json_codec = numcodecs.JSON()\n",
7274
"pickle_codec = numcodecs.Pickle()\n",
@@ -281,6 +283,7 @@
281283
"outputs": [],
282284
"source": [
283285
"from faker import Faker\n",
286+
"\n",
284287
"fake = Faker()"
285288
]
286289
},
@@ -554,8 +557,10 @@
554557
],
555558
"source": [
556559
"np.random.seed(42)\n",
557-
"data4 = np.array([np.random.randint(0, 100, size=np.random.randint(0, 20)).astype('i4')\n",
558-
" for i in range(100000)], dtype=object)\n",
560+
"data4 = np.array(\n",
561+
" [np.random.randint(0, 100, size=np.random.randint(0, 20)).astype('i4') for i in range(100000)],\n",
562+
" dtype=object,\n",
563+
")\n",
559564
"data4"
560565
]
561566
},

numcodecs/abc.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ def __repr__(self):
119119
# by default, assume all non-private members are configuration
120120
# parameters and valid keyword arguments to constructor function
121121

122-
r = '%s(' % type(self).__name__
122+
r = f'{type(self).__name__}('
123123
params = [
124-
'{}={!r}'.format(k, getattr(self, k))
125-
for k in sorted(self.__dict__)
126-
if not k.startswith('_')
124+
f'{k}={getattr(self, k)!r}' for k in sorted(self.__dict__) if not k.startswith('_')
127125
]
128126
r += ', '.join(params) + ')'
129127
return r

numcodecs/astype.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,4 @@ def get_config(self):
7373
}
7474

7575
def __repr__(self):
76-
return '{}(encode_dtype={!r}, decode_dtype={!r})'.format(
77-
type(self).__name__, self.encode_dtype.str, self.decode_dtype.str
78-
)
76+
return f'{type(self).__name__}(encode_dtype={self.encode_dtype.str!r}, decode_dtype={self.decode_dtype.str!r})'

numcodecs/categorize.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,4 @@ def __repr__(self):
9999
labels = repr(self.labels[:3])
100100
if len(self.labels) > 3:
101101
labels = labels[:-1] + ', ...]'
102-
r = '%s(dtype=%r, astype=%r, labels=%s)' % (
103-
type(self).__name__,
104-
self.dtype.str,
105-
self.astype.str,
106-
labels,
107-
)
108-
return r
102+
return f'{type(self).__name__}(dtype={self.dtype.str!r}, astype={self.astype.str!r}, labels={labels})'

numcodecs/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def ensure_contiguous_ndarray_like(buf, max_buffer_size=None, flatten=True) -> N
115115
raise ValueError("an array with contiguous memory is required")
116116

117117
if max_buffer_size is not None and arr.nbytes > max_buffer_size:
118-
msg = "Codec does not support buffers of > {} bytes".format(max_buffer_size)
118+
msg = f"Codec does not support buffers of > {max_buffer_size} bytes"
119119
raise ValueError(msg)
120120

121121
return arr

numcodecs/delta.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def get_config(self):
9191
return dict(id=self.codec_id, dtype=self.dtype.str, astype=self.astype.str)
9292

9393
def __repr__(self):
94-
r = '{}(dtype={!r}'.format(type(self).__name__, self.dtype.str)
94+
r = f'{type(self).__name__}(dtype={self.dtype.str!r}'
9595
if self.astype != self.dtype:
96-
r += ', astype=%r' % self.astype.str
96+
r += f', astype={self.astype.str!r}'
9797
r += ')'
9898
return r

numcodecs/fixedscaleoffset.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,8 @@ def get_config(self):
126126
)
127127

128128
def __repr__(self):
129-
r = '%s(scale=%s, offset=%s, dtype=%r' % (
130-
type(self).__name__,
131-
self.scale,
132-
self.offset,
133-
self.dtype.str,
134-
)
129+
r = f'{type(self).__name__}(scale={self.scale}, offset={self.offset}, dtype={self.dtype.str!r}'
135130
if self.astype != self.dtype:
136-
r += ', astype=%r' % self.astype.str
131+
r += f', astype={self.astype.str!r}'
137132
r += ')'
138133
return r

0 commit comments

Comments
 (0)