-
Notifications
You must be signed in to change notification settings - Fork 0
Genie.py ruff & pyright #45
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
base: main
Are you sure you want to change the base?
Conversation
Failing checks are from files that are to be covered in other PRs afaik |
@@ -31,7 +31,12 @@ | |||
) | |||
|
|||
if TYPE_CHECKING: | |||
from genie_python.genie import PVValue | |||
from genie_python.genie import ( | |||
PVValue, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_epics_api
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To resolve the cyclic import issue, we can break the dependency between genie_python.genie_epics_api
and genie_python.genie
. Since the imports under TYPE_CHECKING
are only used for type hints, we can use forward references (string literals) for type annotations instead of importing the actual symbols. This eliminates the need for the TYPE_CHECKING
block and removes the cyclic dependency.
Specifically:
- Replace the
TYPE_CHECKING
block (lines 33-39) with forward references in the type annotations wherePVValue
,_CgetReturn
,_GetbeamlineparsReturn
, and_GetSampleParsReturn
are used. - Remove the import of
TYPE_CHECKING
from thetyping
module, as it will no longer be needed.
-
Copy modified line R13 -
Copy modified lines R33-R37
@@ -12,3 +12,3 @@ | ||
from io import open | ||
from typing import TYPE_CHECKING, Any, Callable | ||
from typing import Any, Callable | ||
|
||
@@ -32,9 +32,7 @@ | ||
|
||
if TYPE_CHECKING: | ||
from genie_python.genie import ( | ||
PVValue, | ||
_CgetReturn, | ||
_GetbeamlineparsReturn, | ||
_GetSampleParsReturn, | ||
) | ||
# Use forward references for type annotations to avoid cyclic imports | ||
PVValue = "_PVValue" | ||
_CgetReturn = "_CgetReturn" | ||
_GetbeamlineparsReturn = "_GetbeamlineparsReturn" | ||
_GetSampleParsReturn = "_GetSampleParsReturn" | ||
|
from genie_python.genie import PVValue | ||
from genie_python.genie import ( | ||
PVValue, | ||
_CgetReturn, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_epics_api
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
from genie_python.genie import ( | ||
PVValue, | ||
_CgetReturn, | ||
_GetbeamlineparsReturn, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
PVValue, | ||
_CgetReturn, | ||
_GetbeamlineparsReturn, | ||
_GetSampleParsReturn, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_epics_api
definition
import
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
@@ -16,7 +17,13 @@ | |||
from genie_python.utilities import require_runstate | |||
|
|||
if TYPE_CHECKING: | |||
from genie_python.genie import PVValue, _GetspectrumReturn | |||
from genie_python.genie import ( | |||
PVValue, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
from genie_python.genie import PVValue, _GetspectrumReturn | ||
from genie_python.genie import ( | ||
PVValue, | ||
_CgetReturn, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_CgetReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To resolve the cyclic import issue, we can break the dependency loop by moving the type definitions (_CgetReturn
, PVValue
, etc.) into a separate module. This new module will serve as a shared location for type definitions, which can then be imported by both genie_python.genie
and genie_python.genie_simulate_impl
without creating a circular dependency. This approach adheres to the recommendation of moving interdependent parts into a third module.
Steps to fix:
- Create a new module, e.g.,
genie_python.genie_types
, to house the type definitions. - Move the type definitions (
_CgetReturn
,PVValue
, etc.) fromgenie_python.genie
togenie_python.genie_types
. - Update the
TYPE_CHECKING
block ingenie_python.genie_simulate_impl
to import these types fromgenie_python.genie_types
instead ofgenie_python.genie
. - Update any other references to these types in the codebase to use the new module.
-
Copy modified line R20
@@ -19,3 +19,3 @@ | ||
if TYPE_CHECKING: | ||
from genie_python.genie import ( | ||
from genie_python.genie_types import ( | ||
PVValue, |
from genie_python.genie import ( | ||
PVValue, | ||
_CgetReturn, | ||
_GetbeamlineparsReturn, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetbeamlineparsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
PVValue, | ||
_CgetReturn, | ||
_GetbeamlineparsReturn, | ||
_GetSampleParsReturn, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetSampleParsReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
_CgetReturn, | ||
_GetbeamlineparsReturn, | ||
_GetSampleParsReturn, | ||
_GetspectrumReturn, |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetspectrumReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetspectrumReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetspectrumReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetspectrumReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetspectrumReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
'_GetspectrumReturn' may not be defined if module
genie_python.genie
genie_python.genie_simulate_impl
definition
import
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
|
||
from genie_python.utilities import check_break, get_time_delta | ||
|
||
if TYPE_CHECKING: | ||
from genie_python.genie import PVValue |
Check failure
Code scanning / CodeQL
Module-level cyclic import Error
genie_python.genie
genie_python.genie_waitfor
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_waitfor
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_waitfor
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_waitfor
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_waitfor
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_waitfor
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_waitfor
definition
import
'PVValue' may not be defined if module
genie_python.genie
genie_python.genie_waitfor
definition
import
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To resolve the cyclic import issue, we can break the dependency by moving the PVValue
type annotation to a string literal. This approach avoids importing PVValue
entirely, as type annotations can be expressed as strings in Python. This eliminates the cyclic dependency while preserving the type information for static analysis tools.
-
Copy modified line R18
@@ -15,5 +15,5 @@ | ||
if TYPE_CHECKING: | ||
from genie_python.genie import PVValue | ||
from genie_python.genie_epics_api import API | ||
|
||
|
||
NUMERIC_TYPE = (float, int) |
Happy for this to be merged once pyright gives a green tick (which may just be merges/rebase against branches mentioned where these errors were fixed?) |
from genie_python.genie import ( | ||
PVValue, | ||
_CgetReturn, | ||
_GetbeamlineparsReturn, | ||
_GetSampleParsReturn, | ||
) |
Check notice
Code scanning / CodeQL
Unused import Note
Import of '_GetbeamlineparsReturn' is not used.
Import of '_GetSampleParsReturn' is not used.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix the problem, we should remove _CgetReturn
from the import statement on line 34. This will eliminate the unused import while preserving the other imported items that might still be in use. This change will not affect the functionality of the code, as _CgetReturn
is not referenced anywhere in the provided snippet.
@@ -35,3 +35,2 @@ | ||
PVValue, | ||
_CgetReturn, | ||
_GetbeamlineparsReturn, |
Uh oh!
There was an error while loading. Please reload this page.