"""Lorem ipsum"""
import pandas as pd
def demo():
"""Demo for the false positive"""
with pd.ExcelWriter("demo.xlsx") as writer:
print(writer)
The code shown above gives pylint: abstract-class-instantiated(E0110): test.py:8:9: demo: Abstract class 'ExcelWriter' with abstract methods instantiated
No pylint issue: no abstract method left
pd.show_versions()INSTALLED VERSIONS
------------------
commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-54-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.0
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.2.1
setuptools : 40.8.0
Cython : 0.29.12
pytest : 5.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.1.8
lxml.etree : 4.3.4
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : 7.6.1
pandas_datareader: None
bs4 : 4.8.0
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.3.4
matplotlib : 3.1.1
numexpr : 2.6.9
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.0
sqlalchemy : None
tables : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : 1.1.8
cc @WillAyd. Is this a problem in practice?
Thanks @TomAugspurger
Well, it's an exception in my code quality control checks which is difficult to justify. This is especially true because the abstract methods are documented nowhere, so that it is not under control.
@mhooreman you don't actually get back an object with abstract methods though.
In [46]: f = pd.ExcelWriter('./foo.xlsx')
In [47]: type(f)
Out[47]: pandas.io.excel._xlsxwriter._XlsxWriter
In [48]: f.supported_extensions
Out[48]: ('.xlsx',)
So I'd rather say this is a limitation of pylint, that doesn't / can't introspect objects defining __new__.
I have the same issue. Should this issue be reported to pylint instead?
Hi Mark,
Yes, indeed. But I didn't found time to do it now. Can you take it over ...
or wait a bit?
Thanks.
Le mar. 13 août 2019 à 15:14, Marc Skov Madsen notifications@github.com a
écrit :
I have the same issue. Should this issue be reported to pylint instead?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pandas-dev/pandas/issues/27634?email_source=notifications&email_token=ABYIHFQ6DM4UFEW3JXXIB6DQEKXSNA5CNFSM4IHPS2RKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4FTQDY#issuecomment-520828943,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABYIHFR4AC7K2CHVYVXDHQ3QEKXSNANCNFSM4IHPS2RA
.
Can you link back here with what you find from the pylint issue?
FWIW, this sounds somewhat difficult to do in practice. I'm not sure how pylint could know that the object returned by ExcelWriter is an instance of a subclass without actually executing code. I'm not sure whether they execute code or not.
@TomAugspurger , I don't really understand what you say. The code sample at the top of the thread shows the issue and, yes, it seems related to pylint.
I'll open the ticket on the pylint side, with a link to this one.
Created pylint ticket: https://github.com/PyCQA/pylint/issues/3060
Sure I can wait. I have found my way around it. Thanks for the great work with the ExcelWriter.
If you feel that it's really annoying, add # pylint: disable=abstract-class-instantiated right after with line:
with pd.ExcelWriter("demo.xlsx") as writer: # pylint: disable=abstract-class-instantiated
Pylint will temporarily ignore that line.
I know vule24, but it’s a workaround, and I don’t consider a good practice to disable tests which are enabled in the project.
Those disabling are even part of the metrics I have defined.
Looks like this issue is more related to pylint as opposed to pandas. Closing but happy to reopen if there's anything additional to do on the pandas side
Most helpful comment
If you feel that it's really annoying, add
# pylint: disable=abstract-class-instantiatedright afterwithline:with pd.ExcelWriter("demo.xlsx") as writer: # pylint: disable=abstract-class-instantiatedPylint will temporarily ignore that line.