petereon / beaupy

A Python library of interactive CLI elements you have been looking for
https://petereon.github.io/beaupy/
MIT License
192 stars 14 forks source link

AttributeError encountered while running `poetry run poe test` #97

Closed HYP3R00T closed 1 month ago

HYP3R00T commented 1 month ago

As instructed in the Development section of Readme, after forking, cloning and installing dependencies (poetry install), when I tried to run poetry run poe test, I am getting the following error.

beaupy on  master is 󰏗 v3.8.3 via  v3.12.4 (beaupy-py3.12) took 2s
❯ poetry run poe test
Traceback (most recent call last):
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/bin/ward", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/ward/_run.py", line 199, in test
    mod_infos = get_info_for_modules(paths, exclude)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/ward/_collect.py", line 102, in get_info_for_modules
    if is_test_module(mod) and not _is_excluded_module(mod, exclude):
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/ward/_collect.py", line 34, in _is_excluded_module
    return _excluded(_get_module_path(module), exclusions)
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/hyperoot/.cache/pypoetry/virtualenvs/beaupy-7Cx4z3mP-py3.12/lib/python3.12/site-packages/ward/_collect.py", line 30, in _get_module_path
    return Path(module.module_finder.find_module(module.name).path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'FileFinder' object has no attribute 'find_module'

After researching the possible cause of the issue, I found the reason. The problem is with the ward package. In that, if you check the _collect.py file and look for FileFinder object, you will notice that its attribute is now changed to find_spec instead of file_module. Normally, I should report this issue to the official repo of ward but they stopped actively maintaining the package. So, at the moment, we must either fix it or move to another alternative.

If you have any other solution to the said problem, then kindly let me know. I would like to contribute to this project.

petereon commented 1 month ago

Hi, thank you very much for taking a look and investigating.

I believe issue you are encountering was fixed in a most recent beta release: https://github.com/darrenburns/ward/issues/374

But thank you for bringing the issue with maintenance to my attention. That is going to be problematic in a long-run.

I am going to consider some options with regards to that - I wouldn't mind taking over the maintenance of ward myself per-se. I am very hesitant to move to pytest or other alternatives as I find ward to be objectively better.

HYP3R00T commented 1 month ago

Hi, thank you so much for responding.

Judging by their activity, I don't think they will fix it. Are you planning to create a fork of it and publish a new package?

I am very hesitant to move to pytest or other alternatives as I find ward to be objectively better.

I have never used ward. So, if you plan to maintain it (and I know it's a big decision), then I will learn how to utilize it, otherwise, I will stick with popular testing frameworks.

petereon commented 1 month ago

I will look into how well the commitment of maintaining ward fits into my schedule in the near future. But as far as I am aware the issue with 3.12 compatibility is fixed.

Can you share what is your version of ward?

HYP3R00T commented 1 month ago

I have version 0.67.1b0 of bard.

beaupy on  master is 󰏗 v3.8.3 via  v3.12.4 (beaupy-py3.12)
❯ poetry run python -m ward --version
python -m ward, version 0.67.1b0

Apologies for the late response. I was occupied with something personal.

But as far as I am aware the issue with 3.12 compatibility is fixed.

Why can't I run the command if that's the case? I followed the instructions as given in the readme file. The poetry install was all good. But poetry run poe test is not working.

petereon commented 1 month ago

It seems you are not on the latest version, as far as I understand Python 3.12 is supported on ward==0.68.0b0

EDIT: Checking pyproject.toml, I'll make sure to bump the required ward version

HYP3R00T commented 1 month ago

Thanks. Now it is working. So, we need to change the pyproject.toml. I have not checked, but this ward version (ward==0.68.0b0) should be backward compatible. I am creating a new pull request for this change.

petereon commented 1 month ago

Thanks, I've merged #98 and #99.

HYP3R00T commented 1 month ago

Thank you a lot.