Browse Source

tests: Fix mypy test (#1551)

WMOkiishi 2 years ago
parent
commit
0380a60e58

+ 0 - 2
direct/src/showbase/ShowBaseGlobal.py

@@ -64,8 +64,6 @@ hidden = NodePath("hidden")
 
 
 loader: Loader
 loader: Loader
 
 
-direct: "DirectSession"
-
 # Set direct notify categories now that we have config
 # Set direct notify categories now that we have config
 directNotify.setDconfigLevels()
 directNotify.setDconfigLevels()
 
 

+ 2 - 1
direct/src/tkpanels/Inspector.py

@@ -11,6 +11,7 @@ so that I can just type: ``inspect(anObject)`` any time.
 See :ref:`inspection-utilities` for more information.
 See :ref:`inspection-utilities` for more information.
 """
 """
 
 
+from __future__ import annotations
 
 
 __all__ = ['inspect', 'inspectorFor', 'Inspector', 'ModuleInspector', 'ClassInspector', 'InstanceInspector', 'FunctionInspector', 'InstanceMethodInspector', 'CodeInspector', 'ComplexInspector', 'DictionaryInspector', 'SequenceInspector', 'SliceInspector', 'InspectorWindow']
 __all__ = ['inspect', 'inspectorFor', 'Inspector', 'ModuleInspector', 'ClassInspector', 'InstanceInspector', 'FunctionInspector', 'InstanceMethodInspector', 'CodeInspector', 'ComplexInspector', 'DictionaryInspector', 'SequenceInspector', 'SliceInspector', 'InspectorWindow']
 
 
@@ -31,7 +32,7 @@ def inspect(anObject):
 
 
 ### private
 ### private
 
 
-_InspectorMap: "dict[str, str]"
+_InspectorMap: dict[str, str]
 
 
 
 
 def inspectorFor(anObject):
 def inspectorFor(anObject):

+ 3 - 3
direct/src/wxwidgets/WxPandaShell.py

@@ -1,3 +1,5 @@
+from __future__ import annotations
+
 import wx
 import wx
 from wx.lib.agw import fourwaysplitter as FWS
 from wx.lib.agw import fourwaysplitter as FWS
 
 
@@ -9,8 +11,6 @@ from direct.task.TaskManagerGlobal import taskMgr
 from .WxAppShell import WxAppShell
 from .WxAppShell import WxAppShell
 from .ViewPort import Viewport, ViewportManager
 from .ViewPort import Viewport, ViewportManager
 
 
-from typing import Optional
-
 ID_FOUR_VIEW = 401
 ID_FOUR_VIEW = 401
 ID_TOP_VIEW = 402
 ID_TOP_VIEW = 402
 ID_FRONT_VIEW = 403
 ID_FRONT_VIEW = 403
@@ -27,7 +27,7 @@ class WxPandaShell(WxAppShell):
     copyright       = ('Copyright 2010 Disney Online Studios.' +
     copyright       = ('Copyright 2010 Disney Online Studios.' +
                        '\nAll Rights Reserved.')
                        '\nAll Rights Reserved.')
 
 
-    MENU_TEXTS: dict[int, tuple[str, Optional[str]]] = {
+    MENU_TEXTS: dict[int, tuple[str, str | None]] = {
         ID_FOUR_VIEW: ("Four Views", None),
         ID_FOUR_VIEW: ("Four Views", None),
         ID_TOP_VIEW: ("Top View", None),
         ID_TOP_VIEW: ("Top View", None),
         ID_FRONT_VIEW: ("Front View", None),
         ID_FRONT_VIEW: ("Front View", None),

+ 7 - 6
tests/run_mypy.py

@@ -1,7 +1,7 @@
-import os
 import pathlib
 import pathlib
 import shutil
 import shutil
 import subprocess
 import subprocess
+import sys
 import tempfile
 import tempfile
 
 
 
 
@@ -10,15 +10,16 @@ def main():
     direct_src = root / 'direct' / 'src'
     direct_src = root / 'direct' / 'src'
     mypy_config = root / 'mypy.ini'
     mypy_config = root / 'mypy.ini'
     with tempfile.TemporaryDirectory() as temp_dir:
     with tempfile.TemporaryDirectory() as temp_dir:
-        os.environ['MYPYPATH'] = temp_dir
         direct_copy = pathlib.Path(temp_dir, 'direct')
         direct_copy = pathlib.Path(temp_dir, 'direct')
         shutil.copytree(direct_src, direct_copy)
         shutil.copytree(direct_src, direct_copy)
-        subprocess.run([
+        command = [
             'mypy',
             'mypy',
-            str(direct_copy),
+            str(direct_copy.resolve()),
             '--config-file',
             '--config-file',
-            str(mypy_config),
-        ])
+            str(mypy_config.resolve()),
+        ]
+        result = subprocess.run(command, cwd=temp_dir)
+    sys.exit(result.returncode)
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':