OCA/pylint-odoo

[BUG] missing-readme triggers on repos with only one module that has migrations scripts

Closed this issue · 4 comments

Describe the bug

pylint-odoo "thinks" migration folders are Odoo modules when there is only one module in a repo that has a migration script.
And then it gives a missing-readme fail on that migration folder.

To Reproduce

Best quick/easy example I could come up is:

  1. clone https://github.com/OCA/maintenance
  2. Checkout 15.0 branch
  3. Locally delete all modules except for maintenance_equipment_sequence (it has migration script)
  4. Run pre-commit run -a

Or just try to reproduce it having a single module with a migration script.

Expected behavior
Pre-commit checks result being all green

@gaikaz

I couldn't reproduced it locally

In fact, the pre-commit CI is green:

Steps I did locally:

git clone git@github.com:OCA/maintenance.git -b 15.0 /tmp/maintenance && \
     cd /tmp/maintenance && \
     pre-commit run --all

Output:

flake8...................................................................Passed
pylint with optional checks..............................................Passed
- hook id: pylint
- duration: 1.41s
pylint with mandatory checks.............................................Passed

Could you double confirm the steps to reproduce it, please?

@moylop260
Thank you for actually giving this a go.

About the steps, yes, you seem to have skipped step no. 3:

... delete all modules except for maintenance_equipment_sequence ...

So the one-liner should be:

git clone git@github.com:OCA/maintenance.git -b 15.0 /tmp/maintenance &&\
    cd /tmp/maintenance && \
    rm -r */ &&\
    git checkout maintenance_equipment_sequence &&\
    pre-commit run --all

(tho, I wouldn't be running commands from the internet that contain rm 😄 Rather just remove the modules yourself)
This will generate the setup folder again - that's expected. You could try running the pre-commit twice to make it cleaner. But the issue then appears as an output that looks like this:

flake8...................................................................Passed
pylint with optional checks..............................................Passed
- hook id: pylint
- duration: 0.6s

************* Module pre-migration
maintenance_equipment_sequence/migrations/15.0.1.0.0/pre-migration.py:1: [C7902(missing-readme), ] Missing ./README.rst file. Template here: https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst

pylint with mandatory checks.............................................Failed
- hook id: pylint
- exit code: 16

************* Module pre-migration
maintenance_equipment_sequence/migrations/15.0.1.0.0/pre-migration.py:1: [C7902(missing-readme), ] Missing ./README.rst file. Template here: https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst

I got it

Thank you!

Now I have reproduced it

For record,

It is reproduced too using only the following command:

cd maintenance && pylint maintenance_equipment_sequence/__init__.py maintenance_equipment_sequence/migrations/15.0.1.0.0/pre-migration.py

Note for myself:

It is a corner case and weird since that it is not reproduced using only
cd maintenance && pylint maintenance_equipment_sequence/migrations/15.0.1.0.0/pre-migration.py

😢

Please, review the following PR:

I have already reproduced from unittest and fixed