typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Worksheet.row_dimensions type hinting does not work properly

Open JasonMendoza2008 opened this issue 1 year ago • 0 comments

Openpyxl type-hinting Issue

Worksheet's row_dimensions raises a Warning when I put an integer in it (for the index of the row to change the height of) although it works (height is changed and script runs correctly).

MRE:

import openpyxl
from openpyxl.worksheet.worksheet import Worksheet

# Load an existing workbook or create a new one
wb = openpyxl.load_workbook('your_workbook.xlsx')
ws: Worksheet = wb.active

# Set the height of row 1 to 25
ws.row_dimensions[1].height = 25  <-- problem

# Save the changes back to the workbook
wb.save('your_workbook.xlsx')

I'm using Python 3.11.1 and the latest version of openpyxl (3.1.2).

enter image description here

Source of the problem: https://github.com/python/typeshed/tree/ff946a734909f62ec3880cf7c9bbbd0339914081/stubs/openpyxl

StackOverflow: https://stackoverflow.com/questions/78358388/worksheet-row-dimensions-type-hinting-does-not-work-properly

JasonMendoza2008 avatar Apr 29 '24 12:04 JasonMendoza2008