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

Build fails on Python 3.10 due to the collections module #180

Closed
ocervell opened this issue Nov 25, 2021 · 5 comments
Closed

Build fails on Python 3.10 due to the collections module #180

ocervell opened this issue Nov 25, 2021 · 5 comments
Labels
bug Something isn't working python3.10-compat tests Testing improvements / bugs

Comments

@ocervell
Copy link
Collaborator

ocervell commented Nov 25, 2021

gcloud fails to load on Python 3.10:

ERROR: gcloud failed to load: module 'collections' has no attribute 'Mapping'

Also, lint and unit tests fail to run on Python 3.10, example run here:
https://github.com/google/slo-generator/runs/4247056898?check_suite_focus=true

@lvaylet
Copy link
Collaborator

lvaylet commented Mar 20, 2022

Looks like it is a known issue which got fixed a couple of days ago ((Mar 17, 2022) in release 377.0.0: https://issuetracker.google.com/issues/202172882?pli=1

Let me install Python 3.10.2 and confirm make lint and make unit complete successfully.

@ocervell ocervell added bug Something isn't working python3.10-compat tests Testing improvements / bugs labels Mar 27, 2022
@lvaylet
Copy link
Collaborator

lvaylet commented Apr 3, 2022

make lint still fails but I am not surprised as the issue with gcloud is completely independent:

(venv10.3) $ make lint
flake8 --ignore=E302,E203,E261 "slo_generator"/ --max-line-length=80
flake8 --ignore=E302,E203,E261,E402 tests/ --max-line-length=80
find ./"slo_generator" ./tests -name \*.py | xargs pylint --rcfile .pylintrc --ignore-patterns=test_.*?py
************* Module slo_generator.utils
slo_generator/utils.py:422:24: E1101: Module 'collections' has no 'Mapping' member (no-member)

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

make: *** [Makefile:81: pylint] Error 123

make unit fails too. Again, this is expected:

(venv10.3) $ make unit
[...]
  File "/home/laurent/workspace/github/google/slo-generator/venv3.10/lib/python3.10/site-packages/nose/suite.py", line 106, in _set_tests
    if isinstance(tests, collections.Callable) and not is_suite:
AttributeError: module 'collections' has no attribute 'Callable'
make: *** [Makefile:69: unit] Error 1

@lvaylet
Copy link
Collaborator

lvaylet commented Apr 3, 2022

Upon investigation, there is an easy fix for make lint. We just need to replace import collections with import collections.abc and collections.Mapping with collections.abc.Mapping at call site in slo_generator/utils.py.

Fixing make unit in the same way would require updating the nose library itself with similar changes in venv/lib/python3.10/site-packages/nose/suite.py and venv/lib/python3.10/site-packages/nose/suite.py. Unfortunately, nose is no longer being maintained. The latest version (1.3.7) is explicitly not compatible with Python >= 3.10:

and the official website starts with:

Nose has been in maintenance mode for the past several years and will likely cease without a new person/team to take over maintainership. New projects should consider using Nose2, py.test, or just plain unittest/unittest2.

@ocervell WDYT? Is this a good opportunity to move to py.test?

@ocervell
Copy link
Collaborator Author

@lvaylet Sounds good to me. Had no idea nose was going to be discontinued...

@lvaylet lvaylet closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python3.10-compat tests Testing improvements / bugs
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants