Skip to content

Commit

Permalink
Try w/o TextIO parent class
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Feb 27, 2024
1 parent ccf951e commit 3dab48d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 103 deletions.
50 changes: 2 additions & 48 deletions Pythonwin/pywin/framework/stdin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
sys.stdin = sys.stdin.real_file
"""
import sys
from typing import TextIO

get_input_line = input


class Stdin(TextIO):
class Stdin:
def __init__(self):
self.real_file = sys.stdin # NOTE: Likely to be None
self.buffer = ""
Expand Down Expand Up @@ -124,51 +123,6 @@ def readlines(self, *sizehint):
result.append(line)
return result

def __enter__(self):
raise NotImplementedError

def __exit__(self):
raise NotImplementedError

def __iter__(self):
raise NotImplementedError

def __next__(self):
raise NotImplementedError

def close(self):
raise NotImplementedError

def fileno(self):
raise NotImplementedError

def flush(self):
raise NotImplementedError

def readable(self):
raise NotImplementedError

def seek(self):
raise NotImplementedError

def seekable(self):
raise NotImplementedError

def tell(self):
raise NotImplementedError

def truncate(self):
raise NotImplementedError

def writable(self):
raise NotImplementedError

def write(self):
raise NotImplementedError

def writelines(self):
raise NotImplementedError


if __name__ == "__main__":
test_input = r"""this is some test
Expand Down Expand Up @@ -214,4 +168,4 @@ def fake_input(prompt=None):
finally:
get_input_line = input
else:
sys.stdin = Stdin()
sys.stdin = Stdin() # type: ignore[assignment]
58 changes: 3 additions & 55 deletions pywin32_postinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import shutil
import sys
import sysconfig
from typing import TextIO

try:
import winreg as winreg
Expand All @@ -20,7 +19,7 @@
tee_f = open(os.path.join(tempfile.gettempdir(), "pywin32_postinstall.log"), "w")


class Tee(TextIO):
class Tee:
def __init__(self, file):
self.f = file

Expand All @@ -40,57 +39,6 @@ def flush(self):
pass
tee_f.flush()

def __enter__(self):
raise NotImplementedError

def __exit__(self):
raise NotImplementedError

def __iter__(self):
raise NotImplementedError

def __next__(self):
raise NotImplementedError

def close(self):
raise NotImplementedError

def fileno(self):
raise NotImplementedError

def isatty(self):
raise NotImplementedError

def read(self):
raise NotImplementedError

def readable(self):
raise NotImplementedError

def readline(self):
raise NotImplementedError

def readlines(self):
raise NotImplementedError

def seek(self):
raise NotImplementedError

def seekable(self):
raise NotImplementedError

def tell(self):
raise NotImplementedError

def truncate(self):
raise NotImplementedError

def writable(self):
raise NotImplementedError

def writelines(self):
raise NotImplementedError


# For some unknown reason, when running under bdist_wininst we will start up
# with sys.stdout as None but stderr is hooked up. This work-around allows
Expand All @@ -99,8 +47,8 @@ def writelines(self):
if sys.stdout is None:

Check warning on line 47 in pywin32_postinstall.py

View workflow job for this annotation

GitHub Actions / pyright (3.11)

Condition will always evaluate to False since the types "TextIO" and "None" have no overlap (reportUnnecessaryComparison)

Check warning on line 47 in pywin32_postinstall.py

View workflow job for this annotation

GitHub Actions / pyright (3.7)

Condition will always evaluate to False since the types "TextIO" and "None" have no overlap (reportUnnecessaryComparison)

Check warning on line 47 in pywin32_postinstall.py

View workflow job for this annotation

GitHub Actions / pyright (3.9)

Condition will always evaluate to False since the types "TextIO" and "None" have no overlap (reportUnnecessaryComparison)

Check warning on line 47 in pywin32_postinstall.py

View workflow job for this annotation

GitHub Actions / pyright (3.12)

Condition will always evaluate to False since the types "TextIO" and "None" have no overlap (reportUnnecessaryComparison)

Check warning on line 47 in pywin32_postinstall.py

View workflow job for this annotation

GitHub Actions / pyright (3.10)

Condition will always evaluate to False since the types "TextIO" and "None" have no overlap (reportUnnecessaryComparison)

Check warning on line 47 in pywin32_postinstall.py

View workflow job for this annotation

GitHub Actions / pyright (3.8)

Condition will always evaluate to False since the types "TextIO" and "None" have no overlap (reportUnnecessaryComparison)
sys.stdout = sys.stderr

sys.stderr = Tee(sys.stderr)
sys.stdout = Tee(sys.stdout)
sys.stderr = Tee(sys.stderr) # type: ignore[assignment]
sys.stdout = Tee(sys.stdout) # type: ignore[assignment]

com_modules = [
# module_name, class_names
Expand Down

0 comments on commit 3dab48d

Please sign in to comment.