Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python typing error #4844

Closed
geoffthemedio opened this issue Jan 18, 2024 · 10 comments · Fixed by #4845 or #4960
Closed

Python typing error #4844

geoffthemedio opened this issue Jan 18, 2024 · 10 comments · Fixed by #4845 or #4960
Assignees
Labels
category:bug The Issue/PR describes or solves a perceived malfunction within the game. component:internal The Issue/PR deals with any project component that has no explicit `component` label. status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug.
Milestone

Comments

@geoffthemedio
Copy link
Member

In latest master (d598700) but not (0414d6b) with SDK14, running freeorion outputs to the console:

C:\Users\g_top\Desktop\FOSDK14\FreeOrionL>FreeOrion.exe
Traceback (most recent call last):
  File "<string>", line 3, in <module>
ModuleNotFoundError: No module named 'typing'

And in freeorion.log:

10:45:31.391558 {0x00008518} [error] client : PythonParser.cpp:400 : Couldn't find file for module spec typing
10:45:31.392559 {0x00008518} [error] client : PythonCommon.cpp:91 : Missing python exception type
10:45:31.392559 {0x00008518} [error] client : PythonParser.cpp:448 : Unable to parse module file C:/Users/g_top/Desktop/FOSDK14/FreeOrionL/default\scripting\focs\_types.py
@geoffthemedio geoffthemedio added category:bug The Issue/PR describes or solves a perceived malfunction within the game. component:internal The Issue/PR deals with any project component that has no explicit `component` label. labels Jan 18, 2024
@geoffthemedio geoffthemedio added this to the v0.5.1 milestone Jan 18, 2024
@Cjkjvfnby
Copy link
Contributor

This error comes from the helper for the typing, this file should not be executed during script parsing.

I'd recommend one of:

  • exclude files started from underscore,
  • exclude j:/projects/freeorion/default\scripting\focs from parsing
23:45:20.137230 {0x0000109c} [debug] ai : PythonParser.cpp:434 : Executing module file j:/projects/freeorion/default\scripting\focs\_types.py
23:45:20.138230 {0x0000109c} [error] ai : PythonParser.cpp:400 : Couldn't find file for module spec typing

@o01eg
Copy link
Contributor

o01eg commented Jan 21, 2024

@Cjkjvfnby Can we use execution context to conditionally import those files?

@Cjkjvfnby
Copy link
Contributor

Can we use execution context to conditionally import those files?

Not sure what you mean.

This file should not be imported during FOCS parsing. It's imported inside the pyi file that is never executed (static type checker is using it).

I'll check if I can move it somewhere.

@o01eg
Copy link
Contributor

o01eg commented Jan 21, 2024

Can we write something like:

if not ParserContext:
    from focs._species import *

I can define builtins in parser if needed.

@Cjkjvfnby
Copy link
Contributor

Actually I'd prefer to include typing module in Python on Windows. It would be nice to use it in macros.

@Vezzra Vezzra added the status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug. label Jan 24, 2024
@geoffthemedio
Copy link
Member Author

geoffthemedio commented Feb 1, 2024

Still getting errors similar to this in master:

01:06:52.446006 {0x00008494} [debug] server : PythonParser.cpp:434 : Executing module file C:/Users/g_top/Desktop/FOSDK14/FreeOrionAlt/default\scripting\focs\_types.py
01:06:52.446006 {0x00008494} [error] server : PythonParser.cpp:400 : Couldn't find file for module spec typing
01:06:52.447007 {0x00008494} [error] server : PythonCommon.cpp:102 : Traceback (most recent call last):
01:06:52.447007 {0x00008494} [error] server : PythonCommon.cpp:102 :   File "<string>", line 3, in <module>
01:06:52.447007 {0x00008494} [error] server : PythonCommon.cpp:102 : ModuleNotFoundError: No module named 'typing'
01:06:52.447007 {0x00008494} [error] server : PythonParser.cpp:448 : Unable to parse module file C:/Users/g_top/Desktop/FOSDK14/FreeOrionAlt/default\scripting\focs\_types.py

@o01eg o01eg reopened this Feb 1, 2024
@Vezzra Vezzra removed the status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug. label Feb 2, 2024
@geoffthemedio
Copy link
Member Author

@o01eg @Cjkjvfnby any updates about this?

@Cjkjvfnby Cjkjvfnby mentioned this issue Mar 2, 2024
Cjkjvfnby added a commit that referenced this issue Mar 2, 2024
- Bump linter version
- Fix error in log parser
- Fix typing error in the logs #4844
@geoffthemedio
Copy link
Member Author

Still get:

09:47:26.930753 {0x00006fd0} [debug] client : PythonParser.cpp:434 : Executing module file C:/Users/g_top/Desktop/FOSDK14/FreeOrionAlt/default\scripting\focs\_types.py
09:47:26.931753 {0x00006fd0} [error] client : PythonParser.cpp:400 : Couldn't find file for module spec typing
09:47:26.931753 {0x00006fd0} [error] client : PythonParser.cpp:400 : Couldn't find file for module spec focs._types._EffectGroup

@o01eg
Copy link
Contributor

o01eg commented Jun 27, 2024

@geoffthemedio Maybe make parser more strict so such errors will cause tests to fail?

@geoffthemedio
Copy link
Member Author

If that makes sense to you, I have no objection...

@geoffthemedio geoffthemedio added the status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug. label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bug The Issue/PR describes or solves a perceived malfunction within the game. component:internal The Issue/PR deals with any project component that has no explicit `component` label. status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug.
Projects
None yet
4 participants