src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Pydantic/PydanticVisitor.py

branch
eric7
changeset 11150
73d80859079c
parent 11143
ef75c265ab47
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Pydantic/PydanticVisitor.py	Thu Feb 27 09:22:15 2025 +0100
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Pydantic/PydanticVisitor.py	Thu Feb 27 14:42:39 2025 +0100
@@ -37,7 +37,7 @@
         """
         Constructor
 
-        @param errorCallback callback function to register an error
+        @param errorCallback callback function to register an issue
         @type func
         """
         super().__init__()
@@ -94,7 +94,7 @@
             and isFunction(node.value, "Field")
             and len(node.value.args) >= 1
         ):
-            self.__error(node.lineno - 1, node.col_offset, "PYD001")
+            self.__error(node, "PYD-001")
 
     def __checkForPyd002(self, node):
         """
@@ -113,7 +113,7 @@
                 if assign.targets[0].id != "model_config"
             ]
             for assignment in invalidAssignments:
-                self.__error(assignment.lineno - 1, assignment.col_offset, "PYD002")
+                self.__error(assignment, "PYD-002")
 
     def __checkForPyd003(self, node):
         """
@@ -129,7 +129,7 @@
             and len(node.value.keywords) == 1
             and node.value.keywords[0].arg == "default"
         ):
-            self.__error(node.lineno - 1, node.col_offset, "PYD003")
+            self.__error(node, "PYD-003")
 
     def __checkForPyd004(self, node):
         """
@@ -155,7 +155,7 @@
                 None,
             )
             if fieldCall is not None:
-                self.__error(node.lineno - 1, node.col_offset, "PYD004")
+                self.__error(node, "PYD-004")
 
     def __checkForPyd005(self, node):
         """
@@ -173,7 +173,7 @@
                 ):
                     previousTargets.add(stmt.target.id)
                     if previousTargets & extractAnnotations(stmt.annotation):
-                        self.__error(stmt.lineno - 1, stmt.col_offset, "PYD005")
+                        self.__error(stmt, "PYD-005")
 
     def __checkForPyd006(self, node):
         """
@@ -190,7 +190,7 @@
                     stmt.target, ast.Name
                 ):
                     if stmt.target.id in previousTargets:
-                        self.__error(stmt.lineno - 1, stmt.col_offset, "PYD006")
+                        self.__error(stmt, "PYD-006")
 
                     previousTargets.add(stmt.target.id)
 
@@ -209,7 +209,7 @@
                     and stmt.target.id == "__pydantic_config__"
                 ):
                     ##~ __pydantic_config__: ... = ...
-                    self.__error(stmt.lineno - 1, stmt.col_offset, "PYD010")
+                    self.__error(stmt, "PYD-010")
 
                 if isinstance(stmt, ast.Assign) and any(
                     t.id == "__pydantic_config__"
@@ -217,7 +217,7 @@
                     if isinstance(t, ast.Name)
                 ):
                     ##~ __pydantic_config__ = ...
-                    self.__error(stmt.lineno - 1, stmt.col_offset, "PYD010")
+                    self.__error(stmt, "PYD-010")
 
     def visit_ClassDef(self, node: ast.ClassDef) -> None:
         """
@@ -228,7 +228,6 @@
         """
         self.__enterClass(node)
 
-        # TODO: implement these methods
         self.__checkForPyd002(node)
         self.__checkForPyd005(node)
         self.__checkForPyd006(node)

eric ide

mercurial