pylint the following program
import pytz
def example(datetime_obj):
return pytz.UTC.localize(datetime_obj)
E: 5,11: No value for argument 'dt' in unbound method call (no-value-for-parameter)
pylint not complaining about no-value-for-parameter. pytz.UTC is a singleton instance.
No config file found, using default configuration
pylint 1.6.4,
astroid 1.4.8
Python 2.7.11 (default, Jan 22 2016, 08:28:37)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
I can reproduce this and I think it is an occurence of issue https://github.com/PyCQA/pylint/issues/181. What is tripping Pylint in this case is this assignment from pytz (https://github.com/newvem/pytz/blob/master/pytz/__init__.py#L135).
i ran into this today as well in my project when I used exactly the same code as above.
will this be fixed?
EDIT: just saw https://github.com/newvem/pytz/blob/master/pytz/__init__.py#L135
I guess this is beyond pylint's control :/
Work around:
Before:
pytz.UTC.localize(datetime.now())
After:
datetime.now().replace(tzinfo=pytz.UTC)
kinda verbose but works
pytz.utc.localize(datetime.now()) seems to work as well.
I was able to use UTC().localize(myDate, myFormatter) and it stopped complaining as well. Sorry to necro this thread, but hope it helps somebody else in the future!
@CosmicCandi no pb! :smile:
Most helpful comment
pytz.utc.localize(datetime.now())seems to work as well.