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

[Python/Pre-commit] Migrate from type_enforced to mypy #215

Closed
pishoyg opened this issue Aug 24, 2024 · 2 comments
Closed

[Python/Pre-commit] Migrate from type_enforced to mypy #215

pishoyg opened this issue Aug 24, 2024 · 2 comments
Assignees
Labels
dev Why: Developer experience
Milestone

Comments

@pishoyg
Copy link
Owner

pishoyg commented Aug 24, 2024

No description provided.

@pishoyg pishoyg added the dev Why: Developer experience label Aug 24, 2024
@pishoyg pishoyg added this to the Developer Experience milestone Aug 24, 2024
pishoyg added a commit that referenced this issue Aug 24, 2024
`jshint`:
- Make `.jshint` configuration stricter. Notice that we disabled some of
  the rules that we can't force the TypeScript compiler to respect.

`mypy`:
- We disable `mypy` (temporarily) because it requires extensive fixes.
  Filed #215 to reenable it.
- Ignore `.mypy_cache` in `.gitignore`, `stats.sh`, and `.helpers`.

YAML Hooks
- Add `yamllint` hook.
- Add a `.yamlfmt` and `.yamllint` configuration files. Account for them
  in `stats.sh`. The files were required in order to make the two
  linters compatible.

`.pre-commit-config.yaml`
  - Reformatted the file to accommodate the new linter requirements:
    - Add a document start, denoted by `---`.
    - Set the maximum line length to 80. Rewrite many strings, e.g. by
      removing the unnecessary quotes, or using the block scalar
      (denoted by `>` or `|`), or single quotes in order to enable
      splitting strings to multiple lines.
      NOTE: https://yaml-multiline.info/ explains YAML strings well.
    - Rewrote many of the `bash` scripts contained within the file,
      thanks to the newly-discovered YAML string powers:
      - Include `set -o nounset` in many of the `bash` scripts.
      - NOTE: check-do-not-submit` has been fixed. Fix #199.
  - Delete some redundant `types` specifications.
  - Delete the `.git` suffix from The paths of a couple of repos.
  - Changed the TODO about fail-fast to a NOTE because there is
    currently no action required.
  - Changed the TODO about installing more hooks from
    https://pre-commit.com/hooks.html to make it Python-specific,
    because we already acquired most of the other commits.

`json-tool`:
- Run on `.csslintrc` and `.jshintrc` as well.

`typos`:
- Add a new spell-checking hook. (It was problematic, but we're trying
  to retain it.)

Security Hooks:
- We add a few hooks that check for leaked secrets.

Misc:
- Where possible, add links to the configuration pages inside the hook
  config files. The links don't need to be added to
  `.pre-commit-config.yaml`, because it already has links to the rpos
  (albeit not directly to the config pages). But it's helpful to have
  links in such files as `.yamlfmt`, `.yamllint`, and
  `eslint.config.mjs`.
pishoyg added a commit that referenced this issue Aug 26, 2024
@pishoyg pishoyg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2024
@pishoyg pishoyg reopened this Aug 26, 2024
@pishoyg
Copy link
Owner Author

pishoyg commented Aug 26, 2024

This will probably make your type_enforced setup unnecessary.
Try to make mypy work, possibly by configuring the invocation manually rather than relying on the hook's default entry field.

@pishoyg pishoyg modified the milestones: Developer Experience, Platform Aug 26, 2024
@pishoyg pishoyg changed the title [Python/Pre-commit] Appease and Enable mypy [Python/Pre-commit] Migrate from type_enforced to mypy Aug 31, 2024
pishoyg added a commit that referenced this issue Aug 31, 2024
Run `mypy` from a script that triggers it for each project (though now
we have placeholders for certain projects, rather than actual triggers),
and triggers it once for all files that are not part of any projects.

Side changes:
- Define the `_grep` helper. See `.helpers` for more information.
- Run `shellcheck` with `-x` to allow it to follow sourced files.
- Appease `mypy` for shared (non-project-specific) files.
pishoyg added a commit that referenced this issue Aug 31, 2024
pishoyg added a commit that referenced this issue Aug 31, 2024
pishoyg added a commit that referenced this issue Aug 31, 2024
NOTE: We deleted the type `field.grp`. It was too costly to retain it in
this commit. There is a chance we will have to introduce it for #75 or
something else.
pishoyg added a commit that referenced this issue Aug 31, 2024
pishoyg added a commit that referenced this issue Aug 31, 2024
@pishoyg pishoyg self-assigned this Aug 31, 2024
@pishoyg
Copy link
Owner Author

pishoyg commented Aug 31, 2024

KELLIA and Crum left! The rest is done.

pishoyg added a commit that referenced this issue Sep 1, 2024
Running `make crum test` doesn't introduce any changes.
pishoyg added a commit that referenced this issue Sep 1, 2024
Since `morphology/__init__.py` was created in
40719db, we need to prefix imports with
`from morphology`. I don't know how this wasn't caught in the pre-commit
runs of 40719db though!
pishoyg added a commit that referenced this issue Sep 1, 2024
Running `make kellia test` doesn't introduce any changes.
@pishoyg pishoyg closed this as completed in eb73e03 Sep 1, 2024
pishoyg added a commit that referenced this issue Sep 1, 2024
- Delete two no-longer-used constants.
- Use our `_grep` helper to suppress failures when no match is found.
@pishoyg pishoyg added this to coptic Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Why: Developer experience
Projects
Archived in project
Development

No branches or pull requests

1 participant