Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
VadVergasov opened this issue Jan 25, 2023 · 2 comments
Closed

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

VadVergasov opened this issue Jan 25, 2023 · 2 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@VadVergasov
Copy link

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

@VadVergasov VadVergasov added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 25, 2023
@nickdrozd
Copy link
Collaborator

This was fixed with #7824 and will be available in version 2.16.

@nickdrozd nickdrozd closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2023
@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Jan 26, 2023

Thank you for opening the issue though :) You can upgrade to 2.16.0b1 in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

3 participants