Enforcing function keyword arguments in imported functions

Hello!
Is it currently possible with Flake8 or any of its plugins to enforce the code to use keyword arguments in function calls, when the function is imported from a module/library? At least flake8-functions does not support this.
If not, I would like to request this (most likely best suited as optional) rule to be added. My motivation is that it would make code more readable, as one would understand the role of the passed variables better without checking the target function or its documentation.
Example:
from foo import bar
baz = "" bar(baz=baz) # Allowed bar(baz) # Not allowed
Thank you for your time and all the work you do regarding Flake8.
Markus

Flake8 doesn't follow imports and thus will never enforce this.
Sent from my phone with my typo-happy thumbs. Please excuse my brevity
On Thu, Apr 14, 2022, 11:53 Markus Toivonen markus.toivonen@hoxhunt.com wrote:
Hello!
Is it currently possible with Flake8 or any of its plugins to enforce the code to use keyword arguments in function calls, when the function is imported from a module/library? At least flake8-functions does not support this.
If not, I would like to request this (most likely best suited as optional) rule to be added. My motivation is that it would make code more readable, as one would understand the role of the passed variables better without checking the target function or its documentation.
Example:
*from foo import bar*
*baz = ""*
*bar(baz=baz) # Allowed*
*bar(baz) # Not allowed*
Thank you for your time and all the work you do regarding Flake8.
Markus _______________________________________________ code-quality mailing list -- code-quality@python.org To unsubscribe send an email to code-quality-leave@python.org https://mail.python.org/mailman3/lists/code-quality.python.org/ Member address: graffatcolmingov@gmail.com

On Thu, 14 Apr 2022, 17:53 Markus Toivonen, markus.toivonen@hoxhunt.com wrote:
Hello!
Is it currently possible with Flake8 or any of its plugins to enforce the code to use keyword arguments in function calls, when the function is imported from a module/library?
If you want to enforce the use of keyword arguments, you can use keyword only arguments:
def baz(*, baz): ...
can only be called as baz(baz=...)!

Hello,
There's an old issue in pylint asking for something close to this (only if the passed values are litteral, but for all functions, not specifically for libraries) : https://github.com/PyCQA/pylint/issues/385
I think it makes more sense to not make any distinction between lib/external code but feel free to discuss the specifics of the feature in the issue itself.
Pierre
Le jeu. 14 avr. 2022 à 19:13, Daniel Pope lord.mauve@gmail.com a écrit :
On Thu, 14 Apr 2022, 17:53 Markus Toivonen, markus.toivonen@hoxhunt.com wrote:
Hello!
Is it currently possible with Flake8 or any of its plugins to enforce the code to use keyword arguments in function calls, when the function is imported from a module/library?
If you want to enforce the use of keyword arguments, you can use keyword only arguments:
def baz(*, baz): ...
can only be called as baz(baz=...)!
code-quality mailing list -- code-quality@python.org To unsubscribe send an email to code-quality-leave@python.org https://mail.python.org/mailman3/lists/code-quality.python.org/ Member address: pierre.sassoulas@gmail.com
participants (4)
-
Daniel Pope
-
Ian Stapleton Cordasco
-
Markus Toivonen
-
Pierre Sassoulas