bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.36k stars 397 forks source link

Decide what to do about linting #360

Closed sarahmonod closed 1 year ago

sarahmonod commented 1 year ago

As of now, the make lint target will run prettier, which is a NPM package that is used to lint and format markdown, js and css files. There is also a PyPI package called prettier, which pretty prints python dicts.

The prettier dependency is not in the package.json dev dependencies, and is installed manually inside the Dockerfile and the GitHub Action CI.

There is also work under-way to use pre-commit hooks to improve the linting, which may affect this.

What we may want to do one of the following:

  1. Add documentation/comments to explain which prettier to use
  2. Installed prettier automatically, maybe through the package.json dev dependencies section.
stefmolin commented 1 year ago

The pre-commit hook for prettier is mirrors-prettier, and it is not a Python package. However, we can run prettier through pre-commit as follows:

pre-commit run prettier --files <files>

In order to do that we would need to ensure that the hooks were installed:

pre-commit install # needs to be run once

Therefore, if we wanted to use this in make lint, we either need to assume that pre-commit install was run previously, or have the make lint command check and run the install before running prettier.

As for the GitHub Actions, we can switch to run the pre-commit hooks in addition to mypy and remove the npm install -g prettier logic and just replace it with the pre-commit install.