pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.33k stars 1.14k forks source link

Building error when trying to create ast representation of module sphinx configuration module (in which we extend a sphinxcontrib-bibtex dataclass) #7418

Closed tyralla closed 2 years ago

tyralla commented 2 years ago

Bug description

Since astroid 2.12.6, when parsing the following file:

# -*- coding: utf-8 -*-
# pylint: skip-file
# due to conforming to the "Sphinx style"
#
# HydPy documentation build configuration file, created by
# sphinx-quickstart on Thu Jun 09 14:33:31 2016.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import dataclasses
import os
import sys
from typing import Any, Callable, Dict

import pybtex.plugin
from pybtex.database import Person
from pybtex.richtext import Tag, Text
from pybtex.style.formatting.plain import Style as PlainFormattingStyle
from pybtex.style.names.plain import NameStyle as PlainNameStyle
from pybtex.style.names import name_part
from pybtex.style.template import Node

import sphinxcontrib.bibtex.plugin
from sphinxcontrib.bibtex.style.referencing import BracketStyle
from sphinxcontrib.bibtex.style.referencing.author_year import AuthorYearReferenceStyle
from sphinxcontrib.bibtex.style.referencing.basic_author_year import (
    BasicAuthorYearTextualReferenceStyle,
)
from sphinxcontrib.bibtex.style.template import reference, join, year

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("..\\..\\..\\"))
sys.path.insert(0, os.path.abspath("."))

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.napoleon",
    "sphinx.ext.intersphinx",
    "sphinx.ext.viewcode",
    "sphinx.ext.inheritance_diagram",
    "sphinx.ext.mathjax",
    "sphinx.ext.doctest",
    "sphinxcontrib.bibtex",
    "sphinxcontrib.fulltoc",
    "integrationtest_extension",
    "defaultlinks_extension",
]

autoclass_content = "class"
autodoc_default_options = {"undoc-members": None}
autodoc_member_order = "bysource"

# Napoleon settings
napoleon_google_docstring = False
napoleon_numpy_docstring = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = False
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = False
napoleon_use_rtype = False

intersphinx_mapping = {
    "python": ("https://docs.python.org/3", None),
    "numpy": ("https://numpy.org/doc/stable", None),
    "scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
    "matplotlib": ("https://matplotlib.org/", None),
    "pandas": ("https://pandas.pydata.org/pandas-docs/dev", None),
}

mathjax_path = (
    "https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
)
mathjax3_config = {"displayAlign": "left"}

# Configure sphinxcontrib-bibtex *******************************************************

HYDPYNAMESTYLE = "hydpynamestyle"
HYDPYBIBLIOGRAPHYSTYLE = "hydpybibliographystyle"
HYDPYREFERENCESTYLE = "hydpyreferencestyle"

class HydPyNameStyle(PlainNameStyle):
    """Change compared to the base class: write last names in bold letters."""

    def format(self, person: Person, abbr: bool = False) -> Text:
        text_bold = [Tag("b", Text.from_latex(name)) for name in person.last_names]
        return join[
            name_part(tie=True, abbr=abbr)[
                person.rich_first_names + person.rich_middle_names
            ],
            name_part(tie=True)[person.rich_prelast_names],
            name_part[text_bold],
            name_part(before=", ")[person.rich_lineage_names],
        ]

pybtex.plugin.register_plugin("pybtex.style.names", HYDPYNAMESTYLE, HydPyNameStyle)

class HydPyBibliographyStyle(PlainFormattingStyle):
    """Change compared to the base class: use `HydPyNameStyle`."""

    default_name_style = HYDPYNAMESTYLE

pybtex.plugin.register_plugin(
    "pybtex.style.formatting", HYDPYBIBLIOGRAPHYSTYLE, HydPyBibliographyStyle
)

class HydPyTextualReferenceStyle(BasicAuthorYearTextualReferenceStyle):
    """Change compared to the base class: the hyperlink to the bibliography comprises
    the full reference."""

    def inner(self, role_name: str) -> Node:
        return reference[
            join(sep=self.text_reference_sep)[
                self.person.author_or_editor_or_title(full="s" in role_name),
                join[self.bracket.left, year, self.bracket.right],
            ]
        ]

@dataclasses.dataclass
class HydPyReferenceStyle(AuthorYearReferenceStyle):
    """Changed compared to the base class: use round brackets instead of square
    brackets; use `HydPyTextualReferenceStyle`."""

    _make_bracketstylefield: Callable[[], Any] = lambda: dataclasses.field(
        default_factory=lambda: BracketStyle(left="(", right=")")
    )

    bracket_parenthetical: BracketStyle = _make_bracketstylefield()
    bracket_textual: BracketStyle = _make_bracketstylefield()
    bracket_author: BracketStyle = _make_bracketstylefield()
    bracket_label: BracketStyle = _make_bracketstylefield()
    bracket_year: BracketStyle = _make_bracketstylefield()

    def __post_init__(self) -> None:
        super().__post_init__()
        for style in self.styles:
            if isinstance(style, BasicAuthorYearTextualReferenceStyle):
                style.__class__ = HydPyTextualReferenceStyle

sphinxcontrib.bibtex.plugin.register_plugin(
    "sphinxcontrib.bibtex.style.referencing", HYDPYREFERENCESTYLE, HydPyReferenceStyle
)

bibtex_bibfiles = ["refs.bib"]
bibtex_default_style = HYDPYBIBLIOGRAPHYSTYLE
bibtex_reference_style = HYDPYREFERENCESTYLE

# **************************************************************************************

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# The suffix of source filenames.
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = "index"

# General information about the project.
project = "HydPy"
copyright = "2022, HydPy Developers"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "5.1"
# The full version, including alpha/beta/rc tags.
release = "5.1a0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
# add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []

# -- Options for HTML output ---------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
html_theme = "default"

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
html_theme_options = {
    "stickysidebar": True,
    "sidebarwidth": 300,
    "body_max_width": "100%",
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
# html_title = None

# A shorter title for the navigation bar.  Default is the same as html_title.
# html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "HydPy_Logo.png"

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = []
html_extra_path = ["html_"]

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
# html_last_updated_fmt = '%b %d, %Y'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}

# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}

# If false, no module index is generated.
# html_domain_indices = True

# If false, no index is generated.
# html_use_index = True

# If true, the index is split into individual pages for each letter.
# html_split_index = False

# If true, links to the reST sources are added to the pages.
# html_show_sourcelink = True

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = "HydPydoc"

# -- Options for LaTeX output --------------------------------------------------

latex_elements: Dict[str, str] = {
    # The paper size ('letterpaper' or 'a4paper').
    #'papersize': 'letterpaper',
    # The font size ('10pt', '11pt' or '12pt').
    #'pointsize': '10pt',
    # Additional stuff for the LaTeX preamble.
    #'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
    ("index", "HydPy.tex", "HydPy Documentation", "HydPy Developers", "manual"),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
# latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False

# If true, show page references after internal links.
# latex_show_pagerefs = False

# If true, show URL addresses after external links.
# latex_show_urls = False

# Documents to append as an appendix to all manuals.
# latex_appendices = []

# If false, no module index is generated.
# latex_domain_indices = True

# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "hydpy", "HydPy Documentation", ["HydPy Developers"], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False

# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (
        "index",
        "HydPy",
        "HydPy Documentation",
        "HydPy Developers",
        "HydPy",
        "One line description of project.",
        "Miscellaneous",
    ),
]

# Documents to append as an appendix to all manuals.
# texinfo_appendices = []

# If false, no module index is generated.
# texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'

pylint crashed with a AstroidBuildingError and with the following stacktrace:

Traceback (most recent call last):
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\pylint\lint\pylinter.py", line 991, in get_ast
    return MANAGER.ast_from_file(filepath, modname, source=True)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\manager.py", line 117, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\builder.py", line 135, in file_build
    return self._post_build(module, builder, encoding)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\builder.py", line 161, in _post_build
    module = self._manager.visit_transforms(module)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\manager.py", line 94, in visit_transforms
    return self._transform.visit(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 89, in visit
    return self._visit(module)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 54, in _visit
    visited = self._visit_generic(value)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 61, in _visit_generic
    return [self._visit_generic(child) for child in node]
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 61, in <listcomp>
    return [self._visit_generic(child) for child in node]
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 67, in _visit_generic
    return self._visit(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 57, in _visit
    return self._transform(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 39, in _transform
    ret = transform_func(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\brain\brain_dataclasses.py", line 97, in dataclass_transform
    init_str = _generate_dataclass_init(
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\brain\brain_dataclasses.py", line 235, in _generate_dataclass_init
    base_init: FunctionDef | None = base.locals["__init__"][0]
TypeError: 'Uninferable' object is not subscriptable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\pylint\lint\pylinter.py", line 690, in _get_asts
    ast_per_fileitem[fileitem] = self.get_ast(
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\pylint\lint\pylinter.py", line 1010, in get_ast
    raise astroid.AstroidBuildingError(
astroid.exceptions.AstroidBuildingError: Building error when trying to create ast representation of module 'hydpy.docs.sphinx.conf'

### Configuration

```ini
[Master]

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-allow-list=hydpy.cythons.autogen.smoothutils

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=unittests*

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=

# Use multiple processes to speed up Pylint.
jobs=1

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=

# Pickle collected data for later comparisons.
persistent=yes

# Specify a configuration file.
#rcfile=

# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages
suggestion-mode=yes

# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=yes

[MESSAGES CONTROL]

# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=attribute-defined-outside-init,
        cyclic-import,
        duplicate-code,
        eval-used,
        exec-used,
        function-redefined,
        global-statement,
        no-member,
        too-many-function-args,
        trailing-comma-tuple,
        trailing-whitespace,
        unused-wildcard-import,
        useless-super-delegation,
        too-many-ancestors

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=c-extension-no-member,
       useless-suppression

[REPORTS]

# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)

# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details
#msg-template=

# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio).You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=text

# Tells whether to display a full report or only the messages
reports=no

# Activate the evaluation score.
score=yes

[REFACTORING]

# Maximum number of nested blocks for function / method body
max-nested-blocks=5

# Complete name of functions that never returns. When checking for
# inconsistent-return-statements if a never returning function is called then
# it will be considered as an explicit return statement and no message will be
# printed.
never-returning-functions=optparse.Values,sys.exit

[BASIC]

# Naming style matching correct argument names
argument-naming-style=snake_case

# Regular expression matching correct argument names. Overrides argument-
# naming-style
argument-rgx=[a-z0-9_]{1,60}$

# Naming style matching correct attribute names
attr-naming-style=snake_case

# Regular expression matching correct attribute names. Overrides attr-naming-
# style
attr-rgx=[a-z0-9_]{1,60}$

# Bad variable names which should always be refused, separated by a comma
bad-names=foo,
          bar,
          baz,
          toto,
          tutu,
          tata

# Naming style matching correct class attribute names
class-attribute-naming-style=any

# Regular expression matching correct class attribute names. Overrides class-
# attribute-naming-style
#class-attribute-rgx=

# Naming style matching correct class names
class-naming-style=PascalCase

# Regular expression matching correct class names. Overrides class-naming-style
class-rgx=(?:[A-Z_][a-z0-9_]*)+

# Naming style matching correct constant names
const-naming-style=UPPER_CASE

# Regular expression matching correct constant names. Overrides const-naming-
# style
const-rgx=[a-zA-Z0-9_]{1,60}$

# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1

# Naming style matching correct function names
function-naming-style=snake_case

# Regular expression matching correct function names. Overrides function-
# naming-style
#function-rgx=

# Good variable names which should always be accepted, separated by a comma
good-names=

# Include a hint for the correct naming format with invalid-name
include-naming-hint=no

# Naming style matching correct inline iteration names
inlinevar-naming-style=any

# Regular expression matching correct inline iteration names. Overrides
# inlinevar-naming-style
#inlinevar-rgx=

# Naming style matching correct method names
method-naming-style=snake_case

# Regular expression matching correct method names. Overrides method-naming-
# style
#method-rgx=

# Naming style matching correct module names
module-naming-style=snake_case

# Regular expression matching correct module names. Overrides module-naming-
# style
#module-rgx=

# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=

# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_

# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty,
                 hydpy.core.propertytools.BaseProperty

# Naming style matching correct variable names
variable-naming-style=snake_case

# Regular expression matching correct variable names. Overrides variable-
# naming-style
variable-rgx=[a-z0-9_]{1,60}$

[FORMAT]

# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$

# Number of spaces of indent required inside a hanging  or continued line.
indent-after-paren=4

# String used as indentation unit. This is usually "    " (4 spaces) or "\t" (1
# tab).
indent-string='    '

# Maximum number of characters on a single line.
max-line-length=88

# Maximum number of lines in a module
max-module-lines=100000

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no

# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no

[LOGGING]

# Logging modules to check that the string format arguments are in logging
# function parameter format
logging-modules=logging

[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=FixMe

[SIMILARITIES]

# Ignore comments when computing similarities.
ignore-comments=yes

# Ignore docstrings when computing similarities.
ignore-docstrings=yes

# Ignore imports when computing similarities.
ignore-imports=no

# Minimum lines number of a similarity.
min-similarity-lines=4

[SPELLING]

# Limits count of emitted suggestions for spelling mistakes
max-spelling-suggestions=4

# Spelling dictionary name. Available dictionaries: none. To make it working
# install python-enchant package.
spelling-dict=

# List of comma separated words that should not be checked.
spelling-ignore-words=

# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=

# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
spelling-store-unknown-words=no

[TYPECHECK]

# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=

# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes

# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes

# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=

# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes

# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1

# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1

[VARIABLES]

# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=

# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes

# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,
          _cb

# A regular expression matching the name of dummy variables (i.e. expectedly
# not used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_

# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*|^ignored_|^unused_

# Tells whether we should check for unused import in __init__ files.
init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins

[CLASSES]

# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,
                      __new__

# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
                  _fields,
                  _replace,
                  _source,
                  _make

# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls

# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=mcs

[DESIGN]

# Maximum number of arguments for function / method
max-args=20

# Maximum number of attributes for a class (see R0902).
max-attributes=50

# Maximum number of boolean expressions in a if statement
max-bool-expr=5

# Maximum number of branch for function / method body
max-branches=20

# Maximum number of locals for function / method body
max-locals=50

# Maximum number of parents for a class (see R0901).
max-parents=10

# Maximum number of public methods for a class (see R0904).
max-public-methods=100

# Maximum number of return / yield for function / method body
max-returns=10

# Maximum number of statements in function / method body
max-statements=100

# Minimum number of public methods for a class (see R0903).
min-public-methods=0

[IMPORTS]

# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=yes

# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no

# Deprecated modules which should not be used, separated by a comma
deprecated-modules=optparse,tkinter.tix

# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=

# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=

# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=

# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=

# Force import order to recognize a module as part of a third party library.
known-third-party=enchant

[EXCEPTIONS]

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception

Command used

pylint hydpy

Pylint output

Traceback (most recent call last):
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\pylint\lint\pylinter.py", line 991, in get_ast
    return MANAGER.ast_from_file(filepath, modname, source=True)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\manager.py", line 117, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\builder.py", line 135, in file_build
    return self._post_build(module, builder, encoding)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\builder.py", line 161, in _post_build
    module = self._manager.visit_transforms(module)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\manager.py", line 94, in visit_transforms
    return self._transform.visit(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 89, in visit
    return self._visit(module)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 54, in _visit
    visited = self._visit_generic(value)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 61, in _visit_generic
    return [self._visit_generic(child) for child in node]
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 61, in <listcomp>
    return [self._visit_generic(child) for child in node]
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 67, in _visit_generic
    return self._visit(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 57, in _visit
    return self._transform(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\transforms.py", line 39, in _transform
    ret = transform_func(node)
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\brain\brain_dataclasses.py", line 97, in dataclass_transform
    init_str = _generate_dataclass_init(
  File "C:\HydPy\HydPy\.nox\pylint\lib\site-packages\astroid\brain\brain_dataclasses.py", line 235, in _generate_dataclass_init
    base_init: FunctionDef | None = base.locals["__init__"][0]
TypeError: 'Uninferable' object is not subscriptable
************* Module hydpy.docs.sphinx.conf
hydpy\docs\sphinx\conf.py:1:0: F0002: hydpy\docs\sphinx\conf.py: Fatal error while checking 'hydpy\docs\sphinx\conf.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\tyralla\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-09-06-05-42-48.txt'. (astroid-error)
************* Module hydpy.auxs.anntools
hydpy\auxs\anntools.py:669:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
hydpy\auxs\anntools.py:777:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
hydpy\auxs\anntools.py:1080:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
hydpy\auxs\anntools.py:1102:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
hydpy\auxs\anntools.py:1124:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
hydpy\auxs\anntools.py:1284:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
hydpy\auxs\anntools.py:1288:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
************* Module hydpy.auxs.armatools
hydpy\auxs\armatools.py:633:21: E1102: hydpy.pub.options.reprdigits is not callable (not-callable)
hydpy\auxs\armatools.py:725:17: E1102: hydpy.pub.options.reprdigits is not callable (not-callable)
************* Module hydpy.auxs.calibtools
hydpy\auxs\calibtools.py:41:0: C0103: Type variable name "TypeRule1" doesn't conform to predefined naming style (invalid-name)
hydpy\auxs\calibtools.py:45:0: C0103: Type variable name "TypeRule2" doesn't conform to predefined naming style (invalid-name)
hydpy\auxs\calibtools.py:806:0: I0021: Useless suppression of 'not-callable' (useless-suppression)
************* Module hydpy.auxs.ppolytools
hydpy\auxs\ppolytools.py:694:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
************* Module hydpy.core.devicetools
hydpy\core\devicetools.py:1123:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
************* Module hydpy.core.typingtools
hydpy\core\typingtools.py:22:0: C0103: Type variable name "T1" doesn't conform to predefined naming style (invalid-name)
hydpy\core\typingtools.py:23:0: C0103: Type variable name "T2" doesn't conform to predefined naming style (invalid-name)
hydpy\core\typingtools.py:24:0: C0103: Type variable name "T3" doesn't conform to predefined naming style (invalid-name)
hydpy\core\typingtools.py:44:0: C0103: Type variable name "Float1" doesn't conform to predefined naming style (invalid-name)
hydpy\core\typingtools.py:45:0: C0103: Type variable name "Float2" doesn't conform to predefined naming style (invalid-name)
************* Module hydpy.core.variabletools
hydpy\core\variabletools.py:1027:0: I0021: Useless suppression of 'arguments-differ' (useless-suppression)
************* Module hydpy.cythons.modelutils
hydpy\cythons\modelutils.py:1848:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)

------------------------------------------------------------------
Your code has been rated at 9.99/10 (previous run: 9.99/10, +0.00)

Expected behavior

No crash (and no useless-suppression and invalid-name false positives, but this is another issue)

Pylint version

pylint 2.15.0
astroid 5.0.4
python 3.8.10

OS / Environment

Windows (my computer) and Linux (Travis-CI)

Additional dependencies

sphinx 5.1.1 sphinxcontrib_bibtex 2.4.7

DanielNoord commented 2 years ago

@Pierre-Sassoulas This is a release blocker imo.

Making a PR to fix this somewhere today!

DanielNoord commented 2 years ago

Thanks for the report @tyralla! I have deployed a fix and we should release astroid 2.12.7 somewhere today.

One side note: we advise against upgrading astroid manually. Although this time this was much appreciated as it helped prevent releasing pylint with an avoidable crash, normally we bump astroid within pylint itself. There are instances where upgrading astroid on its own without pylint being ready for it can create issues. So, normally just pinning pylint should give you the last up to date and compatible version of both packages.

Pierre-Sassoulas commented 2 years ago

(astroid get updated automatically in pylint when we release patch versions, but they usually don't break anything)

https://github.com/PyCQA/pylint/blob/3694f4fe58dd7b4d24befcc26794590c9880f731/pyproject.toml#L40

ejolie commented 2 years ago

@Pierre-Sassoulas @DanielNoord Hi! I am also having the same problem. How can I download version 2.15.1? I couldn't find it on the https://pypi.org/ site. May I know when it will be available for download? Thanks!

tyralla commented 2 years ago

@ejolie: you must upgrade astroid (currently 2.12.8), then pylint 2.15.0 does not crash anymore.

ejolie commented 2 years ago

@tyralla Thanks! It works!

Pierre-Sassoulas commented 2 years ago

How can I download version 2.15.1? I couldn't find it on the https://pypi.org/ site.

Thank you for the comment, it made me realize I failed at releasing. I released 2.16.0-dev instead of 2.15.1 (https://pypi.org/project/pylint/2.16.0.dev0/). We're going to skip 2.15.1 and release 2.15.2 directly hopefully today.