Skip to content

Commit 52a6a41

Browse files
glaziermagclaude
andcommitted
examples: stop re-annotating format in bench_diskless.py (mypy 2.0 no-redef)
`for format in [...]` at line 43 defines `format` as str; the later annotated assignment `format: Literal[\"NETCDF3_CLASSIC\"] = ...` is a re-annotation that mypy >= 2.0.0 rejects ([no-redef]), and the lost annotation then makes the `write_netcdf(format=format)` call fail [arg-type]. This keeps the Literal annotation the call needs but gives the second variable its own name. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 6e67576 commit 52a6a41

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎examples/bench_diskless.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def read_netcdf(ncfile):
5353
repr(sum(t.repeat(ntrials,1))/ntrials))
5454

5555
# test diskless=True in nc_open
56-
format: Literal["NETCDF3_CLASSIC"] = 'NETCDF3_CLASSIC' # mypy should know this but it needs help...
56+
fmt: Literal["NETCDF3_CLASSIC"] = 'NETCDF3_CLASSIC' # mypy should know this but it needs help...
5757
trials=50
58-
sys.stdout.write('test caching of file in memory on open for %s\n' % format)
59-
sys.stdout.write('testing file format %s ...\n' % format)
60-
write_netcdf('test1.nc',format=format,closeit=True)
58+
sys.stdout.write('test caching of file in memory on open for %s\n' % fmt)
59+
sys.stdout.write('testing file format %s ...\n' % fmt)
60+
write_netcdf('test1.nc',format=fmt,closeit=True)
6161
ncfile = netCDF4.Dataset('test1.nc',diskless=False)
6262
t = Timer("read_netcdf(ncfile)","from __main__ import read_netcdf,ncfile")
6363
sys.stdout.write('reading (from disk) took %s seconds\n' %

0 commit comments

Comments
 (0)