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

Linting rules are pretty strict #19

Open
mhauru opened this issue Feb 5, 2024 · 2 comments
Open

Linting rules are pretty strict #19

mhauru opened this issue Feb 5, 2024 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@mhauru
Copy link

mhauru commented Feb 5, 2024

This might sometimes be what you want, but it's worth noting that

  • the ruff rules are pretty strict and include automatically fixing a lot of issues. This is very much a matter of taste, but I personally dislike autofixes. For instance, I add an import, don't yet get to adding the part that uses the import, save the file, my editor automatically runs ruff and removes the import as unused.
  • mypy complains a lot, including about missing stub packages and missing type annotations. I think we set it up with "loose" as the setting for typing (@rwood-97 is that right?).

These aren't necessarily issues to be fixed, but I wonder if it would be good to have options for some more relaxed linter/fixer rules when setting up.

Tagging @rwood-97 and @mastoffel since these were observations that came from working on a new repo with them.

@phinate
Copy link
Collaborator

phinate commented Feb 5, 2024

the ruff rules are pretty strict and include automatically fixing a lot of issues.

Can totally see that, which was my first experience using a template like this too.

For instance, I add an import, don't yet get to adding the part that uses the import, save the file, my editor automatically runs ruff and removes the import as unused.

Hotfix for this in particular: in pyproject.toml, add

[tool.ruff.lint]
unfixable = ["F401"]

But I'm really happy you brought this up in general: the really cool thing about making our own template is that we can decide some sensible defaults together (with the option to turn things off!).

We could definitely work on streamlining the process of configuring the linter; I'm aware the "everything on by default" strategy is not that useful when you actually want to customize things.

mypy complains a lot, including about missing stub packages and missing type annotations.

Right. This is something that is fixable usually in the following ways as outlined in the MyPy docs. The usual fix is to install the modules within the pre-commit file like this:

-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.8.0
    hooks:
      - mypy
        id: mypy
        files: src
        additional_dependencies:
          ['numpy', 'types-tqdm', 'click', 'types-jsonpatch', 'types-pyyaml', 'types-jsonschema', 'importlib_metadata', 'packaging']

The brute-force solution that's also shown in that link is to turn on ignore-missing-imports in the pyproject.toml.

I'd love to iterate more on these suggestions though: these are going to be consistent pain points for users, and I want to make sure to mitigate those as much as possible. Feel free to drop more thoughts here on suggestions, or we can talk about it offline!

@phinate phinate added enhancement New feature or request question Further information is requested labels Feb 6, 2024
@phinate
Copy link
Collaborator

phinate commented Apr 29, 2024

Some resolutions from this, after following up offline:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants