Open pylint-bot opened 8 years ago
Originally reported by: BitBucket: felipeochoa, GitHub: @felipeochoa?
openpyxl
One way to see the issue is to run pylint[1] with the following code:
pylint
#!python import openpyxl wb = openpyxl.Workbook() sheet = workbook.get_active_sheet()
sheet has its type incorrectly detected as int rather than Worksheet. The definition of Workbook is as follows:
sheet
int
Worksheet
Workbook
#!python class Workbook(object): ... def get_active_sheet(self): return self.active @property def active(self): return self.worksheets[self._active_sheet_index] @active.setter def active(self, value): self._active_sheet_index = value ... def _read_workbook_settings(self, xml_source): ... self.active = int(view.attrib['activeTab'])
I think the fix would be to cut off the type inference propagation for properties defining a setter, and rely solely on the getter for type inference.
[1]: I think the bug is in astroid, but happy to post it on pylint if that's a better place for it
astroid
Originally reported by: BitBucket: felipeochoa, GitHub: @felipeochoa?
Astroid confused by an
openpyxl
property defined with a setterOne way to see the issue is to run
pylint
[1] with the following code:sheet
has its type incorrectly detected asint
rather thanWorksheet
. The definition ofWorkbook
is as follows:I think the fix would be to cut off the type inference propagation for properties defining a setter, and rely solely on the getter for type inference.
[1]: I think the bug is in
astroid
, but happy to post it onpylint
if that's a better place for it