MartinThoma / openpyxl-stubs

Type stubs for openpyxl
MIT License
9 stars 9 forks source link

'workbook.properties' property is missing in stubs #22

Open Questionsdenombres opened 1 year ago

Questionsdenombres commented 1 year ago

Environment

python 3.10.8 windows 10 IDE: VScode - python - pyright/pylance - mode strict

Context

A workbook has properties: https://openpyxl.readthedocs.io/en/stable/api/openpyxl.packaging.core.html accessible with wb.properties

# \Python\Python310\Lib\site-packages\openpyxl\workbook\workbook.py
        ...
        self.defined_names = DefinedNameList()
        self._external_links = []
        self.properties = DocumentProperties()
        self.security = DocumentSecurity()
        self.__write_only = write_only
       ...

Issue

The property properties isn't described in \Python\Python310\Lib\site-packages\openpyxl-stubs\workbook\workbook.pyi The type checker reports that the property/method is unknown.

Thank you for you great software.

MartinThoma commented 1 year ago

Thank you for putting the effort in it to describe the issue well!

What do you think about creating a PR?

Avasam commented 4 months ago

Whilst it's currently typed as Any/Incomplete, the typeshed stubs do at least show Workbook.properties as existing, so it'll pass pyright even in strict mode. https://github.com/python/typeshed/blob/main/stubs/openpyxl/openpyxl/workbook/workbook.pyi#L43

You can use those stubs from https://pypi.org/project/types-openpyxl/