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
3 changes: 2 additions & 1 deletion docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Maintenance
By :user:`John Kirkham <jakirkham>`, :issue:`375`.

* Remove Python 2 code.
By :user:`Dimitri Papadopoulos Orfanos <DimitriPapadopoulos>` :issue:`368`.
By :user:`Dimitri Papadopoulos Orfanos <DimitriPapadopoulos>` :issue:`368`,
:issue:`387`.

* Support Python 3.11.
By :user:`Dimitri Papadopoulos Orfanos <DimitriPapadopoulos>`, :issue:`369`.
Expand Down
2 changes: 1 addition & 1 deletion numcodecs/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, pref
with open(codec_fn, mode='w') as cf:
_json.dump(codec.get_config(), cf, sort_keys=True, indent=4)
# load config and compare with expectation
with open(codec_fn, mode='r') as cf:
with open(codec_fn) as cf:
Copy link
Member

Choose a reason for hiding this comment

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

Could we keep the mode here? Explicit is better than implicit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand, but pyupgrade or refurb disagree and believe implicit is better than explicit 😄

I believe the rationale is that open() has many default arguments, and all of them are implicit (buffering, encoding, errors, newline, closefd, opener). That's why Python has default arguments. Why make an exception for mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then I don't have strong opinions on the subject. I was myself rather reluctant initially:
codespell-project/codespell#2364 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah mode seems special since it affects whether the file may be modified (or even truncated) when opening

That said, not too worried about it given the placement (in the tests)

Have occasionally run into unexpected default behavior around mode in some libraries. Hence the initial pause

config = _json.load(cf)
assert codec == get_codec(config)

Expand Down
2 changes: 1 addition & 1 deletion numcodecs/vlen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class VLenUTF8(Codec):
for i in range(n_items):
u = input_values[i]
if u is None or u == 0: # treat these as missing value, normalize
u = u''
u = ''
elif not PyUnicode_Check(u):
raise TypeError('expected unicode string, found %r' % u)
b = PyUnicode_AsUTF8String(u)
Expand Down