https://github.com/ofek/hatch-mypyc
Hatch build hook plugin for Mypyc
https://github.com/ofek/hatch-mypyc
build hatch mypy plugin python
Last synced: 9 months ago
JSON representation
Hatch build hook plugin for Mypyc
- Host: GitHub
- URL: https://github.com/ofek/hatch-mypyc
- Owner: ofek
- License: mit
- Created: 2021-12-26T22:18:48.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-30T16:49:35.000Z (almost 2 years ago)
- Last Synced: 2024-12-23T19:10:26.643Z (over 1 year ago)
- Topics: build, hatch, mypy, plugin, python
- Language: Python
- Homepage:
- Size: 68.4 KB
- Stars: 38
- Watchers: 2
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# hatch-mypyc
| | |
| --- | --- |
| CI/CD | [](https://github.com/ofek/hatch-mypyc/actions/workflows/test.yml) [](https://github.com/ofek/hatch-mypyc/actions/workflows/build.yml) |
| Package | [](https://pypi.org/project/hatch-mypyc/) [](https://pypi.org/project/hatch-mypyc/) |
| Meta | [](https://github.com/pypa/hatch) [](https://github.com/psf/black) [](https://github.com/ambv/black) [](https://spdx.org/licenses/) [](https://github.com/sponsors/ofek) |
-----
This provides a [build hook](https://hatch.pypa.io/latest/config/build/#build-hooks) plugin for [Hatch](https://github.com/pypa/hatch) that compiles code with [Mypyc](https://github.com/mypyc/mypyc).
**Table of Contents**
- [Configuration](#configuration)
- [File selection](#file-selection)
- [Mypy arguments](#mypy-arguments)
- [Options](#options)
- [Missing types](#missing-types)
- [License](#license)
## Configuration
The [build hook plugin](https://hatch.pypa.io/latest/plugins/build-hook/) name is `mypyc`.
- ***pyproject.toml***
```toml
[tool.hatch.build.targets.wheel.hooks.mypyc]
dependencies = ["hatch-mypyc"]
```
- ***hatch.toml***
```toml
[build.targets.wheel.hooks.mypyc]
dependencies = ["hatch-mypyc"]
```
### File selection
By default, all files included using the [standard file selection options](https://hatch.pypa.io/latest/config/build/#file-selection) with a `.py` extension will be targeted. You can narrow what files to compile to an even smaller subset with the `include`/`exclude` options, which represent [Git-style glob patterns](https://git-scm.com/docs/gitignore#_pattern_format).
```toml
[build.targets.wheel.hooks.mypyc]
include = ["/src/pkg/server"]
exclude = ["__main__.py"]
```
### Mypy arguments
You can specify extra [Mypy arguments](https://mypy.readthedocs.io/en/stable/command_line.html) with the `mypy-args` option.
```toml
[build.targets.wheel.hooks.mypyc]
mypy-args = [
"--disallow-untyped-defs",
]
```
### Options
You can specify `options` that affect the behavior of [mypycify](https://github.com/python/mypy/blob/v0.930/mypyc/build.py#L429).
```toml
[build.targets.wheel.hooks.mypyc.options]
opt_level = "3"
```
Note:
- the `target_dir` option is used internally and therefore has no effect
## Missing types
If you need more packages at build time in order to successfully type check, you can use the following options where you [configured the plugin](#configuration):
- `dependencies` - add more dependencies alongside `hatch-mypyc`
- `require-runtime-dependencies` - set to `true` to include dependencies defined in the `project.dependencies` array
- `require-runtime-features` - set to an array of named dependency groups that are defined in `project.optional-dependencies`
## License
`hatch-mypyc` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.