Skip to content

Commit bb5f936

Browse files
Apply ruff/tryceratops rule TRY300
TRY300 Consider moving this statement to an `else` block
1 parent b7ee725 commit bb5f936

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

distutils/cygwinccompiler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ def check_config_h():
309309
fn = sysconfig.get_config_h_filename()
310310
try:
311311
config_h = pathlib.Path(fn).read_text(encoding='utf-8')
312+
except OSError as exc:
313+
return (CONFIG_H_UNCERTAIN, f"couldn't read '{fn}': {exc.strerror}")
314+
else:
312315
substring = '__GNUC__'
313316
if substring in config_h:
314317
code = CONFIG_H_OK
@@ -317,8 +320,6 @@ def check_config_h():
317320
code = CONFIG_H_NOTOK
318321
mention_inflected = 'does not mention'
319322
return code, f"{fn!r} {mention_inflected} {substring!r}"
320-
except OSError as exc:
321-
return (CONFIG_H_UNCERTAIN, f"couldn't read '{fn}': {exc.strerror}")
322323

323324

324325
def is_cygwincc(cc):

distutils/file_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ def copy_file( # noqa: C901
140140
if not (os.path.exists(dst) and os.path.samefile(src, dst)):
141141
try:
142142
os.link(src, dst)
143-
return (dst, 1)
144143
except OSError:
145144
# If hard linking fails, fall back on copying file
146145
# (some special filesystems don't support hard linking
147146
# even under Unix, see issue #8876).
148147
pass
148+
else:
149+
return (dst, 1)
149150
elif link == 'sym':
150151
if not (os.path.exists(dst) and os.path.samefile(src, dst)):
151152
os.symlink(src, dst)

0 commit comments

Comments
 (0)