Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Update backend typing section (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
armenzg authored Oct 16, 2023
1 parent 83814b6 commit ef57785
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/docs/workflow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ apply the revert directly to the primary branch.

## Python typechecking

We're slowing working to add typing to our Python codebase, using `mypy` to check types. While we do that, there are a few useful things to know:
We're slowly working to add typing to our Python codebase, using `mypy` to check types. While we do that, there are a few useful things to know:

- As you create or work on Python files, please add typing where you can. If possible, try to follow the [Python typing best practices](https://typing.readthedocs.io/en/latest/source/best_practices.html), which may mean you also have to add `from __future__ import annotations` as the first line of your file. For more information about using types in Python, see [the typing docs](https://typing.readthedocs.io/en/latest/index.html).

- In some repos not all files currently pass a typecheck, so in those repos we're enabling checking on a file-by-file basis. (Look for a `files` entry in the `[mypy]` section of the repo's `mypy.ini` file to see if that's the case for a given repo.) This means that in those repos, adding new files and/or moving or renaming existing files may necessitate a change in the `mypy.ini` file, to add or update the files' paths. Also, if you update a file to include typing, please add it to the list!
- Check that the file you're modifying is not on the exclude list from `pyproject.toml`. In other words, you need to opt-in the file for type checking to happen.

- To test types locally, many repos have a `make` command you can run. (The exact command varies by repo. In both `sentry` and `getsentry` it is `make backend-typing`.) In repos which don't have a make command, you can run `mypy --strict --warn-unreachable --config-file mypy.ini` at the root level of the repo.
- To test types locally, you can run `mypy path/to/file` or just `mypy` to run against all files.

1 comment on commit ef57785

@vercel
Copy link

@vercel vercel bot commented on ef57785 Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

develop – ./

develop.sentry.dev
develop-git-master.sentry.dev

Please sign in to comment.