Skip to content

AttributeError: 'NoneType' object has no attribute 'format' in message.py in 2.5.0 #3564

@rrauenza

Description

@rrauenza

I have a cicd that suddenly started failing because tox started bringing in pylint 2.5.0 (I've now pinned it to < 2.5.0).

I can't share the source code externally so I'll do my best to see if I can track this down just from the stack trace. I apologize I can't provide steps to reproduce -- I hope this stack trace and the template value being None is enough to track down the cause.

Traceback (most recent call last):
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/lib/python3.6/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/lib/python3.6/site-packages/pylint/lint/run.py", line 338, in __init__
    linter.check(args)
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/lib/python3.6/site-packages/pylint/lint/pylinter.py", line 878, in check
    files_or_modules,
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/lib/python3.6/site-packages/pylint/lint/check_parallel.py", line 106, in check_parallel
    linter.reporter.handle_message(msg)
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/lib/python3.6/site-packages/pylint/reporters/text.py", line 151, in handle_message
    self.write_message(msg)
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/lib/python3.6/site-packages/pylint/reporters/text.py", line 141, in write_message
    self.writeln(msg.format(self._template))
  File "/opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/lib/python3.6/site-packages/pylint/message/message.py", line 51, in format
    return template.format(**dict(zip(self._fields, self)))
AttributeError: 'NoneType' object has no attribute 'format'
ERROR: InvocationError for command /opt/gitlab-runner/NCiG8AGt/0/<path>/.tox/pylint/bin/pylint src/ (exited with code 1)

It looks like in message.py, template is None.

In the TextReporter class in text.py, self._template is initialized to be None by the class and not changed, so is passed down to message.py

My pylintrc:

[MASTER]
extension-pkg-whitelist=
ignore=CVS
ignore-patterns=
jobs=0
limit-inference-results=100
load-plugins=
persistent=yes
suggestion-mode=yes
unsafe-load-any-extension=no
[MESSAGES CONTROL]
confidence=
enable=c-extension-no-member
[REPORTS]
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
output-format=text
reports=no
score=yes
[REFACTORING]
max-nested-blocks=5
never-returning-functions=sys.exit
[BASIC]
argument-naming-style=snake_case
argument-rgx=^[a-z][a-z0-9]*((_[a-z0-9]+)*)?$
attr-naming-style=snake_case
bad-names=foo,
          bar,
          baz,
class-attribute-naming-style=any
class-naming-style=PascalCase
const-naming-style=UPPER_CASE
docstring-min-length=-1
function-naming-style=snake_case
good-names=_
include-naming-hint=no
inlinevar-naming-style=any
method-naming-style=snake_case
module-naming-style=snake_case
name-group=
no-docstring-rgx=^_
property-classes=abc.abstractproperty
variable-naming-style=snake_case
[FORMAT]
expected-line-ending-format=
indent-after-paren=4
indent-string='    '
max-line-length=90
max-module-lines=1000
no-space-check=trailing-comma,
               dict-separator
single-line-class-stmt=no
single-line-if-stmt=no
[LOGGING]
logging-format-style=old
logging-modules=logging
[MISCELLANEOUS]
notes=FIXME,
      XXX,
      TODO
[SIMILARITIES]
ignore-comments=yes
ignore-docstrings=yes
ignore-imports=no
min-similarity-lines=4
[SPELLING]
max-spelling-suggestions=4
spelling-dict=
spelling-ignore-words=
spelling-private-dict-file=
spelling-store-unknown-words=no
[STRING]
check-str-concat-over-line-jumps=no
[TYPECHECK]
contextmanager-decorators=contextlib.contextmanager
generated-members=
ignore-mixin-members=yes
ignore-none=yes
ignore-on-opaque-inference=yes
ignored-classes=optparse.Values,thread._local,_thread._local
ignored-modules=
missing-member-hint=yes
missing-member-hint-distance=1
missing-member-max-choices=1
signature-mutators=
[VARIABLES]
additional-builtins=
allow-global-unused-variables=yes
callbacks=cb_,
          _cb
ignored-argument-names=^_$
init-import=no
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
[CLASSES]
defining-attr-methods=__init__,
                      __new__,
                      setUp,
                      __post_init__
exclude-protected=_asdict,
                  _fields,
                  _replace,
                  _source,
                  _make
valid-classmethod-first-arg=cls
valid-metaclass-classmethod-first-arg=cls
[DESIGN]
max-args=10
max-attributes=10
max-bool-expr=5
max-branches=12
max-locals=20
max-parents=20
max-public-methods=20
max-returns=6
max-statements=50
min-public-methods=2
[IMPORTS]
allow-any-import-level=
allow-wildcard-with-all=no
analyse-fallback-blocks=no
deprecated-modules=optparse,tkinter.tix
ext-import-graph=
import-graph=
int-import-graph=
known-standard-library=
known-third-party=enchant
preferred-modules=
[EXCEPTIONS]
overgeneral-exceptions=BaseException,
                       Exception

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions