This question is the same as Pylint false positive when unpacking sys.argv but it had no answer.
I have the following function:
def join(*paths_to_join: str) -> str:
"""Join and returns a normalized path
Args:
*paths_to_join (str): All paths to be joined, as an arbitrary number of strings
Returns:
The normalized joined path
"""
return os.path.normpath((os.path.join(*paths_to_join))
This triggers the following pylint
warning:
E1120: No value for argument 'a' in function call (no-value-for-parameter)
Is it a real warning or a false positive? Can I do something else than disable it?
This is a valid warning. os.path.join()
requires at least one argument, but your function doesn't. So paths_to_join
could be empty.
Change your function to be similar to os.path.join()
def join(first: str, rest: List[str]): -> str:
return os.path.normpath(os.path.join(first, *rest))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.