2023.9.6 duplicate "self" argument in `rdfiltercatalog/__init__.pyi`
Describe the bug
Upgrading to 2023.9.6 fails mypy in my pre-commit when importing FilterCatalogParams:
/home/jacobhucker/miniforge3/envs/min_rep_issue/lib/python3.11/site-packages/rdkit-stubs/Chem/rdfiltercatalog/__init__.pyi:671: error: Duplicate argument "self" in function definition
Found 1 error in 1 file (errors prevented further checking)
Viewing this file, self appears untyped and again typed:
class PythonFilterMatcher(FilterMatcherBase):
__instance_size__: typing.ClassVar[int] = 72
@staticmethod
def __reduce__(*args, **kwargs):
...
def __init__(self, self: typing.Any) -> None:
"""
C++ signature :
void __init__(_object*,_object*)
"""
To Reproduce Minimal conda environment yaml:
name: min_rep_issue
channels:
- conda-forge
dependencies:
- python=3.11.8
- pip
- pip:
- rdkit==2023.9.6
- mypy==1.10.0
Minimal main.py:
from rdkit.Chem.rdfiltercatalog import FilterCatalogParams
if __name__ == "__main__":
_ = FilterCatalogParams()
Running mypy:
$ mypy .
/home/jacobhucker/miniforge3/envs/min_rep_issue/lib/python3.11/site-packages/rdkit-stubs/Chem/rdfiltercatalog/__init__.pyi:671: error: Duplicate argument "self" in function definition
Found 1 error in 1 file (errors prevented further checking)
Expected behavior There should be no errors detected by mypy when scanning the above main.py example.
Configuration (please complete the following information):
- RDKit version: 2023.9.6
- OS: Pop!_OS 22.04 LTS
- Python version (if relevant): 3.11.8
- Are you using conda? In the minimal example yes, but this firstly originated when installing rdkit via poetry
- If you are using conda, which channel did you install the rdkit from? as above
- If you are not using conda: how did you install the RDKit? Via poetry 1.8.2
Thanks for reporting. Automated stub generation with C++ Python wrappers is tricky. I'll fix that.
I have a similar issue with rdkit-stubs/Chem/rdMolDescriptors.pyi:185: error: Duplicate argument "self" in function definition
I've been having the same issues, so far pinning to rdkit=2023.09.5 fixes it, which is okay since for now we only need to worry about this error when running mypy
@ptosco Any updates on this? I'm facing the same issue as @lukasturcani
FWIW I've changed mypy.ini to the following to keep using rdkit version 2023.9.6:
[mypy]
disallow_untyped_defs = True
; disallow_any_unimported = True
no_implicit_optional = True
check_untyped_defs = True
; warn_return_any = True
show_error_codes = True
warn_unused_ignores = True
exclude = venv|.venv
[mypy-rdkit.*]
follow_imports = skip
follow_imports_for_stubs = True
Apologies, I have had very little time for RDKit lately; I’ll try to get this fixed for the next patch release.
Thanks @ptosco! Appreciate the help! 💯
The same problem exist in RDKit 2024.3.5 but in the file rdkit-stubs/Chem/rdMolDescriptors.pyi. In this declaration:
def __init__(self, self: typing.Any, name: str, version: str) -> None:
"""
C++ signature :
void __init__(_object*,_object*,std::string,std::string)
"""
there is 2 self where only one should be needed:
def __init__(self: typing.Any, name: str, version: str) -> None:
"""
C++ signature :
void __init__(_object*,_object*,std::string,std::string)
"""
maybe related to this one: https://github.com/rdkit/rdkit/issues/7554
Yes, they are both showing the same problem, just in different files. I posted in both, because the incriminated file was mentionned ion both. And I'm not sure which one is really active.