-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TYP: typing errors in _xlsxwriter.py #35994 #35995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
2b9d262
2b07bb4
f21a189
fdf141a
5b5f5e0
5243e18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from typing import Dict | ||
|
||
import pandas._libs.json as json | ||
|
||
from pandas.io.excel._base import ExcelWriter | ||
|
@@ -8,7 +10,7 @@ class _XlsxStyler: | |
# Map from openpyxl-oriented styles to flatter xlsxwriter representation | ||
# Ordering necessary for both determinism and because some are keyed by | ||
# prefixes of others. | ||
STYLE_MAPPING = { | ||
STYLE_MAPPING: Dict[str, list] = { | ||
"font": [ | ||
(("name",), "font_name"), | ||
(("sz",), "font_size"), | ||
|
@@ -170,7 +172,7 @@ def __init__( | |
**engine_kwargs, | ||
): | ||
# Use the xlsxwriter module as the Excel writer. | ||
import xlsxwriter | ||
from xlsxwriter import Workbook | ||
|
||
if mode == "a": | ||
raise ValueError("Append mode is not supported with xlsxwriter!") | ||
|
@@ -184,7 +186,7 @@ def __init__( | |
**engine_kwargs, | ||
) | ||
|
||
self.book = xlsxwriter.Workbook(path, **engine_kwargs) | ||
self.book: Workbook = Workbook(path, **engine_kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is a variable type annotation needed here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mypy would see it as
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have see https://mypy.readthedocs.io/en/stable/running_mypy.html#running-mypy-and-managing-imports pandas\io\excel_xlsxwriter.py:190: note: Revealed type is 'Any' do you know how mypy is picking it up as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've got a branch going to try and fix these errors, see https://github.com/pandas-dev/pandas/compare/master...simonjayhawkins:typing?expand=1 There I currently got I think the issue could also be on our side... in
which not only seems redundant but you can't really count on attributes that don't have the relevant protocol, in this case so we have a few options here
IMO
(3) ??? wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think (1) is the best. Adding variable type annotation here does seem odd. |
||
|
||
def save(self): | ||
""" | ||
|
Uh oh!
There was an error while loading. Please reload this page.