Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pylint invalid function name

Tags:

python

pylint

I'm running Pylint 1.7.2 with Python 3.6.2. Pylint is showing the following error:

Invalid function name "create_maximization_option_dataframe" (invalid-name)

I define a function like so in my code:

def create_maximization_option_dataframe(file_name):

The PEP8 style guide basically just says:

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

As far as I'm aware I'm following all the formatting rules for a function name. Does Pylint have some built-in maximum function name length rule that I'm not aware of? I can ignore the Pylint error easily enough but I want to understand why this is happening first.

like image 687
Shakes Avatar asked Jan 29 '18 18:01

Shakes


2 Answers

Make a config file by doing pylint pylint --generate-rcfile. The scope of that depends where you put it. Quoting https://docs.pylint.org/en/1.6.0/run.html

  1. pylintrc in the current working directory
  2. .pylintrc in the current working directory
  3. If the current working directory is in a Python module, Pylint searches up the hierarchy of Python modules until it finds a pylintrc file. This allows you to specify coding standards on a module-by-module basis. Of course, a directory is judged to be a Python module if it contains an init.py file.

  4. The file named by environment variable PYLINTRC

  5. if you have a home directory which isn’t /root: .pylintrc in your home directory
    .config/pylintrc in your home directory

  6. /etc/pylintrc

Sounds like you need option 5 or 6.

In the pylintrc, find this bit

# Regular expression matching correct function names
function-rgx=[a-z_][a-z0-9_]{2,30}$

Change that 30 near the end to 40 or so.

like image 142
ColonelFazackerley Avatar answered Oct 17 '22 22:10

ColonelFazackerley


According to PyLint documentation, a function name must have from 2 to 30 characters. Yours has 36.

like image 28
DYZ Avatar answered Oct 17 '22 22:10

DYZ