Skip to content

AttributeError: 'IfExp' object has no attribute 'value' #8113

Closed as not planned
@VadVergasov

Description

@VadVergasov

Bug description

def calendar_keyboard(
    start_date=datetime.date.today(),
    month=datetime.date.today().replace(day=1),
    mark=None,
) -> InlineKeyboardMarkup:
    matrix = calendar.monthcalendar(start_date.year, month.month)
    buttons = [
        []
        for _ in range(
            len(matrix) + (2 if datetime.date.today().month == month.month else 3)
        )
    ]
    for number, week in enumerate(
        matrix, 1 if datetime.date.today().month == month.month else 2
    ):
        for day in week:
            continue

Configuration

No response

Command used

pylint file.py

Pylint output

pylint crashed with a ``AstroidError`` and with the following stacktrace:

Traceback (most recent call last):
  File "\env\lib\site-packages\pylint\lint\pylinter.py", line 790, in _lint_file
    check_astroid_module(module)
  File "\env\lib\site-packages\pylint\lint\pylinter.py", line 1060, in check_astroid_module
    retval = self._check_astroid_module(
  File "\env\lib\site-packages\pylint\lint\pylinter.py", line 1110, in _check_astroid_module
    walker.walk(node)
  File "\env\lib\site-packages\pylint\utils\ast_walker.py", line 93, in walk
    self.walk(child)
  File "\env\lib\site-packages\pylint\utils\ast_walker.py", line 93, in walk
    self.walk(child)
  File "\env\lib\site-packages\pylint\utils\ast_walker.py", line 90, in walk
    callback(astroid)
  File \env\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 682, in visit_for
    self._check_unnecessary_list_index_lookup(node)
  File "\env\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 2118, in _check_unnecessary_list_index_lookup
    has_start_arg, confidence = self._enumerate_with_start(node)
  File "\env\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 2236, in _enumerate_with_start
    start_val, confidence = self._get_start_value(start_arg)
  File "\env\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 2260, in _get_start_value
    start_val = node.value
AttributeError: 'IfExp' object has no attribute 'value'

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

Traceback (most recent call last):
  File "\env\lib\site-packages\pylint\lint\pylinter.py", line 755, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "\env\lib\site-packages\pylint\lint\pylinter.py", line 792, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError


### Expected behavior

Pylint shouldn't crash.

### Pylint version

```shell
astroid==2.12.13
pylint==2.15.9

OS / Environment

Windows 10 x64, Home, 22H2

Additional dependencies

astroid==2.12.13
black==22.12.0
certifi==2022.12.7
charset-normalizer==2.1.1
click==8.1.3
colorama==0.4.6
dill==0.3.6
Flask==2.2.2
idna==3.4
isort==5.11.4
itsdangerous==2.1.2
Jinja2==3.1.2
lazy-object-proxy==1.9.0
MarkupSafe==2.1.1
mccabe==0.7.0
mypy-extensions==0.4.3
pathspec==0.10.3
platformdirs==2.6.2
pylint==2.15.9
pyTelegramBotAPI==4.9.0
python-dateutil==2.8.2
requests==2.28.1
six==1.16.0
tomli==2.0.1
tomlkit==0.11.6
ujson==5.6.0
urllib3==1.26.13
Werkzeug==2.2.2
wrapt==1.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triage 📥Just created, needs acknowledgment, triage, and proper labelling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions