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

ImportError: cannot import name 'render_group' from 'rich.console' #1795

Closed
shotarok opened this issue Jan 9, 2022 · 10 comments · Fixed by #1797 or redhat-performance/jetpack#425
Closed
Labels

Comments

@shotarok
Copy link

shotarok commented Jan 9, 2022

Summary
  File "/opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/site-packages/ansiblelint/generate_docs.py", line 6, in <module>
    from rich.console import render_group
ImportError: cannot import name 'render_group' from 'rich.console' (/opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/site-packages/rich/console.py)

breaking Deprecated rich.console.RenderGroup, now named rich.console.Group

  • We may want to specify rich>=9.5.1,<11.0.0 on setup.cfg instead of rich>=9.5.1.
Issue Type
  • Bug Report
Ansible and Ansible Lint details
runner@fv-az121-779:~/work/macos-provisioning/macos-provisioning$ ansible --version
ansible [core 2.11.7] 
  config file = None
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/hostedtoolcache/Python/3.10.1/x64/lib/python3.10/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/hostedtoolcache/Python/3.10.1/x64/bin/ansible
  python version = 3.10.1 (main, Dec 14 2021, 13:12:05) [GCC 9.3.0]
  jinja version = 3.0.3
  libyaml = True
runner@fv-az121-779:~/work/macos-provisioning/macos-provisioning$ ansible-lint --version
ansible-lint 5.2.1 using ansible 2.11.7
  • ansible installation method: one of source, pip, OS package
  • ansible-lint installation method: one of source, pip, OS package
OS / ENVIRONMENT
STEPS TO REPRODUCE
Desired Behaviour
  • ansible-lint can run without errors
Actual Behaviour
@ssbarnea
Copy link
Member

ssbarnea commented Jan 9, 2022

Instead of adding the ceiling I would prefer to add support for that version, if not too hard.

@Asya-kawai
Copy link

Asya-kawai commented Jan 9, 2022

I also encountered this error.

Python version:

python -V
Python 3.8.0

Ansible-lint version:

ansible-lint 5.3.1 using ansible 2.12.1
ansible-lint
Traceback (most recent call last):
  File "/home/toshiki/env/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
  File "/home/toshiki/env/lib/python3.8/site-packages/ansiblelint/__main__.py", line 310, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
  File "/home/toshiki/env/lib/python3.8/site-packages/ansiblelint/__main__.py", line 214, in main
    from ansiblelint.generate_docs import rules_as_rich, rules_as_rst, rules_as_str
  File "/home/toshiki/env/lib/python3.8/site-packages/ansiblelint/generate_docs.py", line 6, in <module>
    from rich.console import render_group
ImportError: cannot import name 'render_group' from 'rich.console' (/home/toshiki/env/lib/python3.8/site-packages/rich/console.py)

The reason of this error can be found at #1795 (comment).

  • The rich (v11.0.0) seems to have a breaking change. rich/CHANGELOG.md | 11.0.0 - 2022-01-09 says

breaking Deprecated rich.console.RenderGroup, now named rich.console.Group

We can fix this error occured https://github.com/ansible-community/ansible-lint/blob/main/src/ansiblelint/generate_docs.py#L6 as below to avoid when use The rich v11.0.0.

- from rich.console import render_group
+ from rich.console import group as render_group

or PR: #1796.

I hope that this response will be done as soon as possible.

@bitnik
Copy link

bitnik commented Jan 10, 2022

@ssbarnea when would you make a new relase including this bugfix?

@ssbarnea
Copy link
Member

I will made one today. I am working on addressing few more bits before tagging it.

fnordahl added a commit to openstack-charmers/zosci-config that referenced this issue Jan 10, 2022
markgoddard added a commit to stackhpc/stackhpc-release-train that referenced this issue Jan 10, 2022
@jantari
Copy link

jantari commented Jan 10, 2022

Just had a pipeline finish successfully, fix appears to be live with ansible_lint-5.3.2

Thank you everyone for the fast response ❤️

@jedla01
Copy link

jedla01 commented Jan 10, 2022

This affects 4.3.7 too on Python 3.8.12

Collecting ansible-lint==4.3.7
  Downloading ansible_lint-4.3.7-py2.py3-none-any.whl (79 kB)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/bin/ansible-lint", line 5, in <module>
    from ansiblelint.__main__ import main
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansiblelint/__main__.py", line 37, in <module>
    from ansiblelint.generate_docs import rules_as_rich, rules_as_rst
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansiblelint/generate_docs.py", line 6, in <module>
    from rich.console import render_group
ImportError: cannot import name 'render_group' from 'rich.console' (/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/rich/console.py)```

kenji-miyake pushed a commit to autowarefoundation/autoware_core_universe_prototype that referenced this issue Jan 10, 2022
ansible/ansible-lint#1795
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
srl295 added a commit to srl295/cldr that referenced this issue Jan 10, 2022
srl295 added a commit to srl295/cldr that referenced this issue Jan 10, 2022
mwperina added a commit to mwperina/ovirt-ansible-collection that referenced this issue Jan 11, 2022
Fixes ImportError exceptioin when using rich >= 11.0.0 in ansible-lint:
ansible/ansible-lint#1795

Signed-off-by: Martin Perina <mperina@redhat.com>
mwperina added a commit to mwperina/ovirt-ansible-collection that referenced this issue Jan 11, 2022
Fixes ImportError exceptioin when using rich >= 11.0.0 in ansible-lint:
ansible/ansible-lint#1795

Signed-off-by: Martin Perina <mperina@redhat.com>
@BugBuster1701
Copy link

I have the problem only with ansible-lint 4.3.7 with rich 11.0.0.
My hotfix for Ansible-lint 4.3.7 is, install "rich" in Version <11.0.0. (rich-10.16.2)
pip install 'rich>=10.0.0,<11.0.0'

mwperina added a commit to oVirt/ovirt-ansible-collection that referenced this issue Jan 11, 2022
Fixes ImportError exceptioin when using rich >= 11.0.0 in ansible-lint:
ansible/ansible-lint#1795

Signed-off-by: Martin Perina <mperina@redhat.com>
carneirofc added a commit to lnls-sirius/lnls-ansible that referenced this issue Jan 12, 2022
guits added a commit to ceph/cephadm-ansible that referenced this issue Jan 12, 2022
see ansible/ansible-lint#1795

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
guits added a commit to ceph/cephadm-ansible that referenced this issue Jan 12, 2022
see ansible/ansible-lint#1795

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
guits added a commit to ceph/cephadm-ansible that referenced this issue Jan 12, 2022
see ansible/ansible-lint#1795

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
guits added a commit to ceph/cephadm-ansible that referenced this issue Jan 12, 2022
see ansible/ansible-lint#1795

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
asyedham added a commit to asyedham/jetpack that referenced this issue Jan 13, 2022
venkataanil pushed a commit to redhat-performance/jetpack that referenced this issue Jan 13, 2022
mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795
mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795

Fix ansible-lint errors revealed by new ansible-lint.
mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795

Fix ansible-lint errors revealed by new ansible-lint.
pierre added a commit to killbill/killbill-cloud that referenced this issue Jan 13, 2022
mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795

Fix ansible-lint errors revealed by new ansible-lint.
mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795

Fix ansible-lint errors revealed by new ansible-lint.
mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795

Fix ansible-lint errors revealed by new ansible-lint.
mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795

Fix ansible-lint errors revealed by new ansible-lint.

Exclude files which are not playbooks.
@kustodian
Copy link

@ssbarnea what's the reasoning behind not caping rich (and other libs) to the latest major versions currently available? I understand your fix to make it work with rich 11.0 and older, but tomorrow rich in version 12 might introduce a new breaking change that could break ansible-lint again.

Wouldn't it be safer to set rich>=9.5.1,<12.0.0 and increase the max version in a controllable way when the devs of the ansible-lint project decide?

@ssbarnea
Copy link
Member

ssbarnea commented Jan 13, 2022

To cap or not to cap - that is effectively a gamble. So far we had only one case where rich broke us, even if it has several major versions bumps since we started using it. If 12 will break us I will add the cap, now I just a one off.

The downside of a cap is that is adding some kind of time-bomb, as it would prevent user from installing the tool in the future just because of the metadata. Imagine that two years from now, rich is version 20 and other projects require that newer version. You will not be able to install current version of linter with it, even if the code itself may work, just because that cap.

This is why my take regarding capping is: avoid them unless the projects involved have a bad track of breaking you. Add capping when you know that newer version will break you (basically that can be done by testing with pre-releases or git master branches of involved projects).

Note that might is not will. But adding a cap assures that user will not be able to install your project with newer versions of the capped dependency. That problem is that they may want to do so and I do not want to have to do a new release or even a backport to remove that cap. I already had to so it for many projects.

Also keep in mind that you could make use of our constraints.txt file if you want capped versions. Take a look at https://github.com/ansible-community/ansible-lint/blob/v5.3.2/constraints.txt

mpryc added a commit to mpryc/osp-director-dev-tools that referenced this issue Jan 13, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795

Fix ansible-lint errors revealed by new ansible-lint.

Exclude files which are not playbooks.
martignoni added a commit to moodlebox/moodlebox that referenced this issue Jan 16, 2022
Due to recent issue in the ansible-lint package we need to
bump version which we are using:
  ansible/ansible-lint#1795
Yarboa pushed a commit to redhat-openstack/ansible-nfv that referenced this issue Jan 16, 2022
Due to ansible/ansible-lint#1795
we are required to move to a newer ansible-lint version.

Version 5.0.0 refactored the rules and we must adapt to the new rules.

Updated .ansible-lint.
Excluding the playbook 'playbooks/packet_gen/iperf/performance_scenario.yml'
due to a linting fail that we can not satisfy.

Removing ansible-lint during molecule execution, linting occurs on the
global level during tox execution.

Fixing 'risky-shell-pipe' linting errors.
Fixing 'internal-error' linting errors for molecule and more fixes
to molecule in general.

Excluding rules:
  - 'unnamed-task' # We don't mind having tasks that are unnamed
  - 'no-changed-when' # We don't mind that there will be tasks that will always return ok
  - 'no-handler' # We don't mind that we're running tasks based on a previous task that returned changed
  - 'package-latest' # We don't mind installing latest packages

Change-Id: I057faab90874618933d935bb77ff28663f22e3f0
damiendart added a commit to damiendart/setup that referenced this issue Jan 17, 2022
Update "ansible-lint" dependency to a version that fixes the
"ImportError: cannot import name 'render_group' from 'rich.console'"
error (for more information, please see
<ansible/ansible-lint#1795>).
@batazor
Copy link

batazor commented Jan 18, 2022

I'm still getting this error is there any news?

@ansible ansible locked as resolved and limited conversation to collaborators Jan 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants