Skip to content

Commit d7399ba

Browse files
committed
[#552] Fixed most of the linting errors, except the 35 of the 51 original C901 errors, in DisplayCAL.display_cal module.
1 parent 0c66b19 commit d7399ba

12 files changed

Lines changed: 2915 additions & 1925 deletions

DisplayCAL/argyll_rgb2xyz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
NORMALIZATION_FACTOR["Ynorm"] = 1.0 / NORMALIZATION_FACTOR["Ynorm"]
4646

4747

48-
def xyz_denormalize_remove_glare(x: float, y: float, z:float) -> tuple:
48+
def xyz_denormalize_remove_glare(x: float, y: float, z: float) -> tuple:
4949
"""Convert XYZ to RGB using the inverse of the RGB to XYZ conversion.
5050
5151
Args:

DisplayCAL/audio.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def init(
124124
_INITIALIZED = True
125125
return _SERVER
126126

127+
127128
def _init_wx() -> None:
128129
"""Initialize wx audio subsystem."""
129130
global _SERVER, _LIB, _LIB_VERSION, wx
@@ -177,19 +178,17 @@ def _load_audio_dll(
177178
_SERVER.Mix_LoadWAV_RW.argtypes = [POINTER(SDL_RWops), c_int]
178179
_SERVER.Mix_LoadWAV_RW.restype = POINTER(Mix_Chunk)
179180
_SERVER.Mix_PlayChannelTimed.argtypes = [
180-
c_int,
181-
POINTER(Mix_Chunk),
182-
c_int,
183-
c_int,
184-
]
181+
c_int,
182+
POINTER(Mix_Chunk),
183+
c_int,
184+
c_int,
185+
]
185186
_SERVER.Mix_VolumeChunk.argtypes = [POINTER(Mix_Chunk), c_int]
186187
if _INITIALIZED:
187188
_SERVER.Mix_Quit()
188189
sdl.SDL_Quit()
189190
sdl.SDL_Init(SDL_INIT_AUDIO)
190-
_SERVER.Mix_OpenAudio(
191-
samplerate, MIX_DEFAULT_FORMAT, channels, buffersize
192-
)
191+
_SERVER.Mix_OpenAudio(samplerate, MIX_DEFAULT_FORMAT, channels, buffersize)
193192
_LIB = "SDL"
194193
_LIB_VERSION = "2.0" if libname.startswith("SDL2") else "1.2"
195194
return sdl
@@ -274,13 +273,13 @@ def _init_sdl_linux(samplerate: int, channels: int, buffersize: int) -> None:
274273
sdl = None
275274
for libname in ("SDL2", "SDL2_mixer", "SDL", "SDL_mixer"):
276275
handle = None
277-
# Hard-code lib names for Linux
276+
# Hard-code lib names for Linux
278277
libfn = f"lib{libname}"
279278
if libname.startswith("SDL2"):
280-
# SDL 2.0
279+
# SDL 2.0
281280
libfn += "-2.0.so.0"
282281
else:
283-
# SDL 1.2
282+
# SDL 1.2
284283
libfn += "-1.2.so.0"
285284

286285
sdl = _load_audio_dll(
@@ -332,24 +331,25 @@ def _init_pyo(samplerate: int, channels: int, buffersize: int) -> None:
332331
else:
333332
if isinstance(_SERVER, pyo.Server):
334333
_SERVER.reinit(
335-
sr=samplerate, nchnls=channels, buffersize=buffersize, duplex=0
336-
)
334+
sr=samplerate, nchnls=channels, buffersize=buffersize, duplex=0
335+
)
337336
else:
338337
_SERVER = pyo.Server(
339-
sr=samplerate,
340-
nchnls=channels,
341-
buffersize=buffersize,
342-
duplex=0,
343-
winhost="asio",
344-
).boot()
338+
sr=samplerate,
339+
nchnls=channels,
340+
buffersize=buffersize,
341+
duplex=0,
342+
winhost="asio",
343+
).boot()
345344
_SERVER.start()
346345
_LIB_VERSION = ".".join(str(v) for v in pyo.getVersion())
347346

347+
348348
def _init_pyglet() -> None:
349349
"""Initialize pyglet audio subsystem."""
350350
global _SERVER, _LIB, _LIB_VERSION, pyglet
351351
if not getattr(sys, "frozen", False):
352-
# Use included pyglet
352+
# Use included pyglet
353353
lib_dir = os.path.join(os.path.dirname(__file__), "lib")
354354
if lib_dir not in sys.path:
355355
sys.path.insert(0, lib_dir)
@@ -368,10 +368,10 @@ def _init_pyglet() -> None:
368368
except ImportError:
369369
_LIB = None
370370
else:
371-
# Work around localization preventing fallback to RIFFSourceLoader
371+
# Work around localization preventing fallback to RIFFSourceLoader
372372
pyglet.lib.LibraryLoader.darwin_not_found_error = ""
373373
pyglet.lib.LibraryLoader.linux_not_found_error = ""
374-
# Set audio driver preference
374+
# Set audio driver preference
375375
pyglet.options["audio"] = ("pulse", "openal", "directsound", "silent")
376376
_SERVER = pyglet.media
377377
_LIB_VERSION = pyglet.version
@@ -729,7 +729,6 @@ def is_playing(self) -> bool:
729729
return bool(self._ch is not None and self._server.Mix_Playing(self._ch))
730730
return self._is_playing
731731

732-
733732
def _play_pyglet(self, fade_ms: int = 0, stop_already_playing: bool = True) -> bool:
734733
"""Play the sound using pyglet.
735734

DisplayCAL/colormath.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,9 +1588,7 @@ def is_similar_matrix(
15881588
bool: True if the matrices are equal up to the specified number of
15891589
digits, False otherwise.
15901590
"""
1591-
result = matrix1.rounded(digits) == matrix2.rounded(digits)
1592-
print(f"result: {result}")
1593-
return result
1591+
return matrix1.rounded(digits) == matrix2.rounded(digits)
15941592

15951593

15961594
def is_equal(

DisplayCAL/config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ def load_bitmap(
522522
from DisplayCAL.wx_addons import wx
523523

524524
bmp = None
525-
path = None
526525
width, height, orig_name, name2x, name4x, color, inverted, size = (
527526
extract_image_properties(parts)
528527
)
@@ -544,7 +543,7 @@ def load_bitmap(
544543
if not bmp.IsOk():
545544
path = None
546545
if path:
547-
width, height, path = resize_and_adjust_bitmap(
546+
width, height, path, bmp = resize_and_adjust_bitmap(
548547
path,
549548
parts,
550549
orig_name,
@@ -864,7 +863,7 @@ def resize_and_adjust_bitmap(
864863
bmp = img.ConvertToBitmap()
865864
if not bmp.IsOk():
866865
path = None
867-
return width, height, path
866+
return width, height, path, bmp
868867

869868

870869
def adjust_bitmap_size(
@@ -2036,7 +2035,7 @@ def getcfg(
20362035
and (name != "testchart.file" or value != "auto")
20372036
and (not os.path.isabs(value) or not os.path.exists(value))
20382037
):
2039-
value = get_corrected_colorimeter_path(name, defval, has_default, value)
2038+
value = get_corrected_colorimeter_path(name, value)
20402039
elif name in ("displays", "instruments"):
20412040
if not value:
20422041
return []

DisplayCAL/demjson_compat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ def handle_forward_slash_char(self) -> None:
141141
debug_print("<EXPECT_COMMENT>")
142142
self.expect_comment = True
143143

144-
145144
def handle_multiline_comment(self) -> None:
146145
"""Handle the start of a multiline comment."""
147146
if self.expect_comment:

0 commit comments

Comments
 (0)