Metadata-Version: 2.4
Name: macrotype
Version: 0.2.0
Summary: Generate .pyi stub files from existing modules
Author-email: Kurt Rose <kurt@kurtrose.com>
License: MIT License
        
        Copyright (c) 2025 Kurt Rose
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: mypy; extra == "test"
Requires-Dist: ruff; extra == "test"
Requires-Dist: pytest; extra == "test"
Provides-Extra: build
Requires-Dist: build; extra == "build"
Requires-Dist: twine; extra == "build"
Dynamic: license-file

# Macrotype

Consider this:

```python
VAL = 42

def get() -> type(VAL):
    return VAL
```

This is perfectly valid python, but type checkers don't accept it.
Instead, you are supposed to write out all type references statically,
or use very limited global aliases.

`macrotype` makes this work exactly as you expect, with all static
type checkers.  So your types can be as dynamic as the rest of your
python code.

# How?

`macrotype` is a CLI tool intended to be run before static type checking:

```bash
macrotype your_module
```

`macrotype` imports your modules under normal python,
and then generates corresponding `.pyi` files with
all types pinned statically so the type checker can understand them.

In our example, `macrotype` would generate this:

```python
VAL: int

def get() -> int: ...
```

`macrotype` is the bridge between static type checkers
and your dynamic code.  `macrotype` will import your modules as
python, and then re-export the runtime types back out into a form
that static type checkers can consume.

# What else?

In addition to the CLI tool, there are also helpers for generating
dynamic types.  See `macrotype.meta_types`.  These are intended
for you to import to enable dynamic programming patterns which
would be unthinkable without `macrotype`.
