Skip to content

Commit fd4c92d

Browse files
committed
Fix astroid warnings
1 parent b81afc9 commit fd4c92d

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/genie_python/genie_api_setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ def __init__(self, original_function: Callable) -> None:
284284
def just_path_on_load(self, text: str, act_tok: Any) -> list[str]:
285285
"""
286286
Returns completions for load on a path if load_script in path otherwise returns as before.
287-
Will replace .metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\
288-
org.python.pydev_5.9.2.201708151115\pysrc\_pydev_bundle\pydev_ipython_console_011.py
287+
Will replace .metadata\\.plugins\\org.eclipse.pde.core\\.bundle_pool\\plugins\\
288+
org.python.pydev_5.9.2.201708151115\\pysrc\\_pydev_bundle\\pydev_ipython_console_011.py
289289
290290
This functions will filter out the pydev completions if the line contains load_script.
291291
It know which are the pydev ones because they are marked with the type '11'.

src/genie_python/scanning_instrument_pylint_plugin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TYPE_CHECKING, Any
22

3-
import astroid
43
from astroid import MANAGER
4+
from astroid.nodes import Arguments, ClassDef, FunctionDef, Module
55

66
if TYPE_CHECKING:
77
from pylint.lint import PyLinter
@@ -11,7 +11,7 @@ def register(linter: "PyLinter") -> None:
1111
"""Register the plugin."""
1212

1313

14-
def transform(node: astroid.ClassDef, *args: Any, **kwargs: Any) -> None:
14+
def transform(node: ClassDef, *args: Any, **kwargs: Any) -> None:
1515
"""Add ScanningInstrument methods to the declaring module.
1616
1717
If the given class is derived from ScanningInstrument,
@@ -22,16 +22,16 @@ def transform(node: astroid.ClassDef, *args: Any, **kwargs: Any) -> None:
2222
if node.basenames and "ScanningInstrument" in node.basenames:
2323
public_methods = filter(lambda method: not method.name.startswith("__"), node.methods())
2424
for public_method in public_methods:
25-
if isinstance(node.parent, astroid.Module):
26-
new_func = astroid.FunctionDef(
25+
if isinstance(node.parent, Module):
26+
new_func = FunctionDef(
2727
name=public_method.name,
2828
lineno=0,
2929
col_offset=0,
3030
parent=node.parent,
3131
end_lineno=0,
3232
end_col_offset=0,
3333
)
34-
arguments = astroid.Arguments(
34+
arguments = Arguments(
3535
vararg=None,
3636
kwarg=None,
3737
parent=new_func,
@@ -50,4 +50,4 @@ def transform(node: astroid.ClassDef, *args: Any, **kwargs: Any) -> None:
5050
node.parent.locals[public_method.name] = [new_func]
5151

5252

53-
MANAGER.register_transform(astroid.ClassDef, transform)
53+
MANAGER.register_transform(ClassDef, transform)

tests/test_script_checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import tempfile
2525
import unittest
2626

27-
import astroid
27+
from astroid.nodes import Module
2828

2929
from genie_python.genie_epics_api import API
3030
from genie_python.genie_script_checker import ScriptChecker
@@ -405,17 +405,17 @@ def test_GIVEN_builtin_module_THEN_it_can_safely_be_cached(self):
405405
def test_GIVEN_site_packages_module_THEN_it_can_safely_be_cached(self):
406406
import numpy
407407

408-
mod = astroid.Module(numpy.__name__, numpy.__file__)
408+
mod = Module(numpy.__name__, numpy.__file__)
409409
self.assertTrue(self.checker._can_cache_module("numpy", mod))
410410

411411
def test_GIVEN_user_script_THEN_it_should_not_be_cached(self):
412412
name = "my_user_script"
413-
mod = astroid.Module(name, os.path.join("C:\\", "scripts", "my_user_script.py"))
413+
mod = Module(name, os.path.join("C:\\", "scripts", "my_user_script.py"))
414414
self.assertFalse(self.checker._can_cache_module(name, mod))
415415

416416
def test_GIVEN_instrument_script_THEN_it_should_not_be_cached(self):
417417
name = "my_inst_script"
418-
mod = astroid.Module(
418+
mod = Module(
419419
name,
420420
os.path.join(
421421
"C:\\",

0 commit comments

Comments
 (0)