Tecnativa / doodba-copier-template

A Copier template for Doodba projects
Boost Software License 1.0
86 stars 114 forks source link

Automatic code fix stops working due to vscode update #460

Closed pleirb closed 1 week ago

pleirb commented 7 months ago

When starting vscode in a doodba copier template project, this appears in the lower right corner:

image Translation: You have stopped using linting or formatting settings for Python. See logs for more details. And it directs us to this link: https://github.com/microsoft/vscode-python/wiki/Migration-to-Python-Tools-Extensions

Removing these two lines from doodba.XXX.code-workspace:

"python.linting.flake8Enabled": true,
"python.linting.pylintEnabled": true

The message disappears, but continues without the useful correction functionality

yajo commented 7 months ago

Probably it will have to integrate with https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff now and remove those old linters.

pleirb commented 7 months ago

Probablemente tendrá que integrarse con https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff ahora y eliminar esos viejos linters.

If I find a solution I will publish it, but studying vscode in depth is another of my pending subjects.

pleirb commented 7 months ago

Probablemente tendrá que integrarse con https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff ahora y eliminar esos viejos linters.

If I find a solution I will publish it, but studying vscode in depth is another of my pending subjects.

I found a temporary solution, but it would be nice to have some expert confirm if it is the right way to go. First, add "charliermarsh.ruff" to the extensions list in ./vscode/extensions.json Second, install Ruff on the system. In my case, Ubuntu is in version 23.10, and I must do it with: sudo snap install ruff Although I have seen that it is possible in other distributions to do it with pip Third, remove all the obsolete lines (the ones that are marked off) in the file: doodba.xxx.code-workspace

    "python.formatting.provider": "none",
    "python.linting.flake8Enabled": true,
    "python.linting.ignorePatterns": [
      "/path/to/your/project/odoo/custom/src/odoo/**/*.py"
    ],
    "python.linting.pylintArgs": [
      "--init-hook=\"import sys;sys.path.append('/path/to/your/project/odoo/custom/src/odoo')\"",
      "--load-plugins=pylint_odoo"
    ],
    "python.linting.pylintEnabled": true,

Fourth, uninstall the extensions ms-python.pylint and ms-python.flake8 Fifth, update your template to get the .ruff.toml configuration file copier copy gh:Tecnativa/doodba-copier-template ./ --trust

pleirb commented 4 months ago

Hello community! Question, is there any intention to repair the code-workspace extension file to fix the problems that appear with the latest version of Visual Studio Code (1.90.1)?

imagen

Currently it does not correct my code as it should and I am not being able to debug correctly

pedrobaeza commented 4 months ago

We haven't dug on that for now, but feel free to propose the corresponding patch.

pleirb commented 4 months ago

Thanks, at the moment what version of Visual Studio Code is recommended to use without problems?

pedrobaeza commented 4 months ago

I'm using with the latest and I have warnings and errors. Which ones do you mean?

imagen

pleirb commented 4 months ago

The problems that appear are from library imports and therefore the correction is wrong. I guess it has to do with the linting problem

imagen

pedrobaeza commented 4 months ago

But if I'm not wrong, this wasn't working before either.

pleirb commented 4 months ago

Pero si no me equivoy, esto tampoco estaba funcionando antes.

And what advantage of use could Visual Studio Code have if it is integrated into the code-workspace file generated by dodba copier template if ruff is integrated and the old linters are eliminated as suggested by @yajo

pedrobaeza commented 4 months ago

ruff is one thing, and import sentences another different one.

pleirb commented 4 months ago

Ruff es una cosa, y importoro a otra diferente.

Sorry for my ignorance, yes, it is a code formatter, the thing is that I assumed that this tool works well if it manages to import all the libraries and maybe it had some automatic way to do it or based on the configuration file (code-workspace)

pedrobaeza commented 4 months ago

ruff is run when you run manually pre-commit or automatic if you configure the repository, but it's not directly attached to VSCode IDE. You may want to do it on IDE file save, but it's not put (it was not either when using previous linter + formatter, as having pre-commit is enough).

pleirb commented 4 months ago

ruffse ejecuta cuando se ejecuta manualmente pre-commito o automático si configura el repositorio, pero no está conectado directamente a VSCode IDE. Usted puede querer hacerlo en el archivo IDE guardado, pero no se pone (no fue ni cuando se usaba linter anterior formatter, ya que tener pre-comprometer es suficiente).

Thanks, for the moment then I guess I won't miss anything if I remove the flake8Enabled, pylintEnabled lines from the code-workspace file and the chrome extension from .vscode/extensiions.json These two things are what were bothering me with warnings when launching Visual Studio Code every day

pleirb commented 1 week ago

After so much time it seems that uninstalling the ms-python.python extension and installing it again apparently causes ms-python.black-formatter to also be installed, thus solving the warning problem