How to deal with Pylint's “too-many-instance-attributes” message?

后端 未结 4 1688
北恋
北恋 2021-01-31 02:10

I have just tried to lint some code with Pylint, and the last remaining error is

R0902: too-many-instance-attributes (8/7)

I understand the rat

4条回答
  •  悲&欢浪女
    2021-01-31 02:23

    This is an ideological objection, but personally I tend to try to make these kind of changes as universal as possible. If 7 is not enough instances in one file, and I choose to allow it here, why not everywhere? I don't always make changes to the lint rules across the board, but I at least consider it. To that end, if you want to make an across the board change, in your .pylintrc file change max-attributes=7 in the DESIGN section.

    Since I think 7 is a little low across the board, I changed:

    [DESIGN]
    max-attributes=7
    

    to

    max-attributes=12
    

提交回复
热议问题