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 #23

Open
ZanSara opened this issue Apr 14, 2023 · 2 comments
Open

Linting #23

ZanSara opened this issue Apr 14, 2023 · 2 comments
Milestone

Comments

@ZanSara
Copy link
Contributor

ZanSara commented Apr 14, 2023

As discussed in #18, we can consider adding some linting and code formatting facilities to this project. I opened the issue here not to make noise on generalpackager, but feel free to move it there if you deem it suitable.

I'm basing this recommendation on what we have in Haystack and related projects, like Canals. Canals is way simpler and smaller than Haystack, so you can take a look at it to make yourself an idea of what I have in mind 🙂

  • Code formatting: black
  • Type checking: mypy
  • Linting: pylint

These tools need close to no configuration, but all the config would go in the pyproject.toml file. So I recommend introducing that one first (ManderaGeneral/generalpackager#78).

They could run in the CI and fail if they hit any error. This is an example workflow from Canals running all these three (plus the unit tests): https://github.com/deepset-ai/canals/blob/main/.github/workflows/tests.yml

We also add these same tools in the pre-commit hooks like this: https://github.com/deepset-ai/canals/blob/main/.pre-commit-config.yaml In this way, the CI almost never fails and it can be used to make sure contributors installed the pre-commit hooks.

@Mandera Mandera mentioned this issue Apr 16, 2023
@Mandera
Copy link
Contributor

Mandera commented Apr 16, 2023

black and pylint sounds great for all repos! Not sure about mypy. I'm open to making it an option for each repo and then we'll enable it with generalimport to begin with. What are the pros with type checking? I do love type hinting but I don't understand enforcing it

@ZanSara
Copy link
Contributor Author

ZanSara commented Apr 17, 2023

I found mypy to be quite helpful in general. It does not force you to type everything, it can normally guess the types correctly regardless, and when it raises issues it's always catching some small bug. So it has been a widely net positive for me to use it.

Interestingly for me pylint is less useful because, although it helps a lot, it also has an opinionated view and sometimes it conflicts with mine 😄

Of course it's up to you. I run it like mypy generalimport/ --exclude='test/' on the codebase and I got just three errors, so it should be easy to integrate. But it's not a dealbreaker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants