Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4181b6

Browse files
committed
more lints
1 parent 90317aa commit b4181b6

1 file changed

Lines changed: 15 additions & 24 deletions

File tree

IPython/utils/_process_win32.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22
33
This file is only meant to be imported by process.py, not by end-users.
44
"""
5-
6-
#-----------------------------------------------------------------------------
7-
# Copyright (C) 2010-2011 The IPython Development Team
8-
#
9-
# Distributed under the terms of the BSD License. The full license is in
10-
# the file COPYING, distributed as part of this software.
11-
#-----------------------------------------------------------------------------
12-
13-
#-----------------------------------------------------------------------------
14-
# Imports
15-
#-----------------------------------------------------------------------------
16-
17-
# stdlib
185
import ctypes
196
import os
207
import subprocess
@@ -25,18 +12,15 @@
2512
from subprocess import STDOUT
2613
from threading import Thread
2714
from types import TracebackType
28-
from typing import IO, Any, List, Optional
15+
from typing import List, Optional
2916

3017
from . import py3compat
3118
from ._process_common import arg_split as py_arg_split
3219

33-
# our own imports
3420
from ._process_common import process_handler, read_no_interrupt
3521
from .encoding import DEFAULT_ENCODING
3622

37-
#-----------------------------------------------------------------------------
38-
# Function definitions
39-
#-----------------------------------------------------------------------------
23+
4024

4125
class AvoidUNCPath:
4226
"""A context manager to protect command execution from UNC paths.
@@ -72,7 +56,10 @@ def __enter__(self) -> Optional[str]:
7256
return None
7357

7458
def __exit__(
75-
self, exc_type: Optional[type[BaseException]], exc_value: Optional[BaseException], traceback:TracebackType
59+
self,
60+
exc_type: Optional[type[BaseException]],
61+
exc_value: Optional[BaseException],
62+
traceback: TracebackType,
7663
) -> None:
7764
if self.is_unc_path:
7865
os.chdir(self.path)
@@ -142,14 +129,15 @@ def system(cmd: str) -> Optional[int]:
142129
"""
143130
# The controller provides interactivity with both
144131
# stdin and stdout
145-
#import _process_win32_controller
146-
#_process_win32_controller.system(cmd)
132+
# import _process_win32_controller
133+
# _process_win32_controller.system(cmd)
147134

148135
with AvoidUNCPath() as path:
149136
if path is not None:
150137
cmd = '"pushd %s &&"%s' % (path, cmd)
151138
return process_handler(cmd, _system_body)
152139

140+
153141
def getoutput(cmd: str) -> str:
154142
"""Return standard output of executing cmd in a shell.
155143
@@ -171,9 +159,10 @@ def getoutput(cmd: str) -> str:
171159
out = process_handler(cmd, lambda p: p.communicate()[0], STDOUT)
172160

173161
if out is None:
174-
out = b''
162+
out = b""
175163
return py3compat.decode(out)
176164

165+
177166
try:
178167
windll = ctypes.windll # type: ignore [attr-defined]
179168
CommandLineToArgvW = windll.shell32.CommandLineToArgvW
@@ -193,7 +182,7 @@ def arg_split(
193182
194183
If strict=False, process_common.arg_split(...strict=False) is used instead.
195184
"""
196-
#CommandLineToArgvW returns path to executable if called with empty string.
185+
# CommandLineToArgvW returns path to executable if called with empty string.
197186
if commandline.strip() == "":
198187
return []
199188
if not strict:
@@ -209,11 +198,13 @@ def arg_split(
209198
)
210199
if arg is not None
211200
]
212-
LocalFree(result_pointer)
201+
# for side effects
202+
_ = LocalFree(result_pointer)
213203
return result
214204
except AttributeError:
215205
arg_split = py_arg_split
216206

207+
217208
def check_pid(pid: int) -> bool:
218209
# OpenProcess returns 0 if no such process (of ours) exists
219210
# positive int otherwise

0 commit comments

Comments
 (0)