Skip to content

pyright errors in generated code #304

Description

Using yardl version 0.6.7 commit 8b8c611, I got lots of errors like this

 /home/kris/devel/PETSIRD/python/petsird/binary.py:63:38 - error: Argument of type "DICOMPatientInformation" cannot be assigned to parameter "value" of type "void" in function "write_numpy"
    "DICOMPatientInformation" is not assignable to "void" (reportArgumentType)

Generated code is

   def write(self, stream: _binary.CodedOutputStream, value: DICOMPatientInformation) -> None:
        if isinstance(value, np.void):
            self.write_numpy(stream, value)
            return
        self._write(stream, value.patient_id, value.patients_sex, value.patients_size, value.patients_weight, value.patients_body_mass_index)

I guess the type for value needs to include np.void.

Class definition is https://github.com/ETSInitiative/PETSIRD/blob/75e3323b1ac1dffe2ef57a64377be9d3cefd88a2/model/DICOMTypes.yml, but I get this for (nearly?) every type.

I also get a few other errors on that tree:

  /home/kris/devel/PETSIRD/python/petsird/_binary.py:1095:13 - error: Argument of type "type[Any] | dtype[Any] | _HasDType[dtype[Any]] | _HasNumPyDType[dtype[Any]] | tuple[_DTypeLikeNested, _DTypeLikeNested] | list[Any] | _DTypeDict | str | Unknown" cannot be assigned to parameter "dtype" of type "dtype[Any]" in function "_get_dtype_and_subarray_shape"
    Type "type[Any] | dtype[Any] | _HasDType[dtype[Any]] | _HasNumPyDType[dtype[Any]] | tuple[_DTypeLikeNested, _DTypeLikeNested] | list[Any] | _DTypeDict | str | Unknown" is not assignable to type "dtype[Any]"
      "_DTypeDict" is not assignable to "dtype[Any]" (reportArgumentType)
/home/kris/devel/PETSIRD/python/petsird/_ndjson.py
  /home/kris/devel/PETSIRD/python/petsird/_ndjson.py:868:18 - error: Cannot access attribute "ndim" for class "object"
    Attribute "ndim" is unknown (reportAttributeAccessIssue)
  /home/kris/devel/PETSIRD/python/petsird/_ndjson.py:871:67 - error: "object" is not iterable
    "__iter__" method not defined (reportGeneralTypeIssues)
  /home/kris/devel/PETSIRD/python/petsird/_ndjson.py:901:67 - error: "object_" is not iterable
    "__iter__" method not defined (reportGeneralTypeIssues)
  /home/kris/devel/PETSIRD/python/petsird/_ndjson.py:999:13 - error: Argument of type "type[Any] | dtype[Any] | _HasDType[dtype[Any]] | _HasNumPyDType[dtype[Any]] | tuple[_DTypeLikeNested, _DTypeLikeNested] | list[Any] | _DTypeDict | str | Unknown" cannot be assigned to parameter "dtype" of type "dtype[Any]" in function "_get_dtype_and_subarray_shape"
    Type "type[Any] | dtype[Any] | _HasDType[dtype[Any]] | _HasNumPyDType[dtype[Any]] | tuple[_DTypeLikeNested, _DTypeLikeNested] | list[Any] | _DTypeDict | str | Unknown" is not assignable to type "dtype[Any]"
      "_DTypeDict" is not assignable to "dtype[Any]" (reportArgumentType)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions