pyproject.toml: pyright: ignore reportPrivateUsage
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 2 Oct 2024 03:07:07 +0000 (23:07 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2024 02:56:57 +0000 (22:56 -0400)
Our code does not follow the convention of treating identifiers starting
with an underscore as private.  For instance, the `bt2` module exposes
types like `_EventMessageConst`.  Even though the user is not expected
to create objects of that type, they can still use the type in a type
check like:

    if type(msg) is bt2._EventMessageConst:

That produces a `reportPrivateUsage` in pyright / pylance.  Disable that
check to get rid of a lot of false positives.

Change-Id: I78a19653aafb923d3e429b9b321cb1f87372c83e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13307
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
pyproject.toml
tests/utils/python/normand.py
tests/utils/python/tjson.py

index fb033ec7f387586b225e0f14c63fa4215dbc7c53..9ceb20327ec0e8e57f604ae10761ac052fc0764a 100644 (file)
@@ -26,3 +26,6 @@ extend_skip_glob = [
     "tests/utils/python/typing/typing.py",
 ]
 length_sort = true
+
+[tool.pyright]
+reportPrivateUsage = false
index 4c7063d4a14f908111fc7025ffb80e16f689c840..06d9570a9b749663fbec85a5e6bb8fd781bd598b 100644 (file)
@@ -109,8 +109,7 @@ class _ScalarItem(_Item):
     # Returns the size, in bytes, of this item.
     @property
     @abc.abstractmethod
-    def size(self) -> int:
-        ...
+    def size(self) -> int: ...
 
 
 # A repeatable item.
@@ -618,7 +617,7 @@ class ParseError(RuntimeError):
 
     def _add_msg(self, msg: str, text_loc: TextLocation):
         self._msgs.append(
-            ParseErrorMessage._create(  # pyright: ignore[reportPrivateUsage]
+            ParseErrorMessage._create(
                 msg, text_loc
             )
         )
@@ -633,12 +632,12 @@ class ParseError(RuntimeError):
 
 # Raises a parsing error, forwarding the parameters to the constructor.
 def _raise_error(msg: str, text_loc: TextLocation) -> NoReturn:
-    raise ParseError._create(msg, text_loc)  # pyright: ignore[reportPrivateUsage]
+    raise ParseError._create(msg, text_loc)
 
 
 # Adds a message to the parsing error `exc`.
 def _add_error_msg(exc: ParseError, msg: str, text_loc: TextLocation):
-    exc._add_msg(msg, text_loc)  # pyright: ignore[reportPrivateUsage]
+    exc._add_msg(msg, text_loc)
 
 
 # Appends a message to the parsing error `exc` and reraises it.
@@ -761,7 +760,7 @@ class _Parser:
     # Current text location.
     @property
     def _text_loc(self):
-        return TextLocation._create(  # pyright: ignore[reportPrivateUsage]
+        return TextLocation._create(
             self._line_no, self._col_no
         )
 
@@ -2105,8 +2104,7 @@ class _NodeVisitor(ast.NodeVisitor):
         self._parent_is_call = False
 
     @abc.abstractmethod
-    def _visit_name(self, name: str):
-        ...
+    def _visit_name(self, name: str): ...
 
 
 # Expression validator: validates that all the names within the
@@ -2607,7 +2605,7 @@ class _Gen:
             # Process the contained group
             init_data_size = len(self._data)
             parse_error_msg = (
-                ParseErrorMessage._create(  # pyright: ignore[reportPrivateUsage]
+                ParseErrorMessage._create(
                     parse_error_msg_text, item.text_loc
                 )
             )
@@ -2833,9 +2831,7 @@ def parse(
         init_offset,
         init_byte_order,
     )
-    return ParseResult._create(  # pyright: ignore[reportPrivateUsage]
-        gen.data, gen.variables, gen.labels, gen.offset, gen.bo
-    )
+    return ParseResult._create(gen.data, gen.variables, gen.labels, gen.offset, gen.bo)
 
 
 # Raises a command-line error with the message `msg`.
index 59a5a1c48e1271c693c08b15dadf8cfbf56f2a98..55e8873ae6da70388a80d7de50d3663da236ee80 100644 (file)
@@ -221,8 +221,8 @@ def _check_type(val: Val, expected_type: Type[Val]):
         raise TypeError(
             "`{}`: expecting {} value, got {}".format(
                 val.path,
-                expected_type._name,  # pyright: ignore [reportPrivateUsage]
-                type(val)._name,  # pyright: ignore [reportPrivateUsage]
+                expected_type._name,
+                type(val)._name,
             )
         )
 
This page took 0.027573 seconds and 4 git commands to generate.