pyright errors in generated code
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 35
- Forks
- 14
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 1
Description
Using yardl version 0.6.7 commit 8b8c6110854037608f0d608ffeaf1a561f9ab4a0, 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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported pyright errors in the generated Python files binary.py, _binary.py, and _ndjson.py using the DICOMTypes.yml example. Trace those outputs back to the generator and inspect how NumPy-backed values and types are represented. Done means the reported generated-code type errors are resolved and pyright passes for the affected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100