{"id":23480026,"url":"https://github.com/RightTyper/RightTyper","last_synced_at":"2025-08-27T08:32:04.402Z","repository":{"id":252958321,"uuid":"836469696","full_name":"RightTyper/RightTyper","owner":"RightTyper","description":"A fast and efficient type assistant for Python, including tensor shape inference","archived":false,"fork":false,"pushed_at":"2025-08-25T20:05:19.000Z","size":1250,"stargazers_count":331,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-25T22:08:33.857Z","etag":null,"topics":["python","typing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RightTyper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-31T23:28:14.000Z","updated_at":"2025-08-25T20:05:23.000Z","dependencies_parsed_at":"2024-08-29T13:45:38.903Z","dependency_job_id":"2f35e0e5-c5dd-4512-bea7-45cbf9ad46da","html_url":"https://github.com/RightTyper/RightTyper","commit_stats":null,"previous_names":["righttyper/righttyper"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/RightTyper/RightTyper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RightTyper%2FRightTyper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RightTyper%2FRightTyper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RightTyper%2FRightTyper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RightTyper%2FRightTyper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RightTyper","download_url":"https://codeload.github.com/RightTyper/RightTyper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RightTyper%2FRightTyper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272310303,"owners_count":24911651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","typing"],"created_at":"2024-12-24T20:00:46.240Z","updated_at":"2025-08-27T08:32:04.366Z","avatar_url":"https://github.com/RightTyper.png","language":"Python","funding_links":[],"categories":["Python","Tools","Recently Updated"],"sub_categories":["Helper tools to add annotations to existing code","[Dec 24, 2024](/content/2024/12/24/README.md)"],"readme":"# RightTyper\n\n![pyversions](https://img.shields.io/pypi/pyversions/righttyper?logo=python\u0026logoColor=FBE072)\n[![pypi](https://img.shields.io/pypi/v/righttyper?color=blue)](https://pypi.org/project/righttyper/)\n![Downloads](https://static.pepy.tech/badge/righttyper)\n[![Downloads](https://static.pepy.tech/badge/righttyper/month)](https://pepy.tech/project/righttyper)\n![tests](https://github.com/righttyper/righttyper/workflows/tests/badge.svg)\n\nRightTyper is a Python tool that generates types for your function arguments and return values.\nRightTyper lets your code run at nearly full speed (around 30% overhead) and little memory overhead.\nAs a result, you won't experience slowdowns in your code or large memory consumption while using it,\nallowing you to integrate it with your standard tests and development process.\nBy virtue of its design, and in a significant departure from previous approaches, RightTyper only captures the most commonly used types,\nletting a type checker like `mypy` detect possibly incorrect type mismatches in your code.\n\nYou can run RightTyper with arbitrary Python programs and it will generate types for every function that gets executed.\nIt works great in combination with [pytest](https://docs.pytest.org/):\n\n```bash\npython3 -m righttyper run -m pytest --continue-on-collection-errors /your/test/dir\n```\n\nIn addition to generating types, RightTyper has the following features:\n\n* It efficiently computes type annotation \"coverage\" for a file or directory of files\n* It infers shape annotations for NumPy/JAX/PyTorch tensors, compatible with [`jaxtyping`](https://docs.kidger.site/jaxtyping/) and [`beartype`](https://github.com/beartype/beartype) or [`typeguard`](https://typeguard.readthedocs.io/en/latest/).\n\nFor details about how RightTyper works, please see the following paper: **[RightTyper: Effective and Efficient Type Annotation for Python](https://www.arxiv.org/abs/2507.16051)**.\n\n\n## Performance Comparison\nThe graph below presents the overhead of using RightTyper versus two previous tools, PyAnnotate and MonkeyType, across a range of benchmarks.\nOn average, RightTyper imposes only 30% overhead compared to running plain Python.\nOn running the tests of a popular package (black), RightTyper imposes only 20% overhead, while MonkeyType slows down execution by over 6x.\nIn extreme cases, MonkeyType runs over 270x slower than RightTyper.\n\n![Overhead](docs/benchmark_comparison_execution_times.png)\n\n## Usage\nInstall RightTyper from `pip` as usual:\n\n```bash\npython3 -m pip install righttyper\n```\n\nTo use RightTyper, simply run your script with `python3 -m righttyper run` instead of `python3`:\n\n```bash\npython3 -m righttyper run your_script.py [args...]\n```\n\nThis will execute `your_script.py` with RightTyper's monitoring\nenabled. The type signatures of all functions will be recorded and\noutput to a file named `righttyper.out`. The file contains, for every\nfunction, the signature, and a diff of the original function with the\nannotated version. It also optionally (with the `--infer-shapes` flag)\ngenerates `jaxtyping`-compatible shape\nannotations for NumPy/JAX/PyTorch tensors. Below is an example:\n\n```diff\ntest-hints.py:\n==============\n\nbarnacle\n\n- def barnacle(x):\n+ def barnacle(x: jaxtyping.Float64[np.ndarray, \"10 D1\"]) -\u003e jaxtyping.Float64[np.ndarray, \"D1\"]:\n\nfooq\n\n- def fooq(x: int, y) -\u003e bool:\n+ def fooq(x: int, y: int) -\u003e bool:\n?                   +++++\n```\n\nTo add type hints directly to your code, use this command:\n\n```bash\npython3 -m righttyper run --output-files --overwrite your_script.py [args...]\n```\n\nTo do the same with `pytest`:\n\n```bash\npython3 -m righttyper run --output-files --overwrite -m pytest [pytest-args...]\n```\n\n### Type ergonomics\nRightTyper may infer types that include deeply nested generics.\nWhile such precise types improve recall in type checking, they can be difficult for developers to read and understand.\nTo improve the ergonomics of such annotations, RightTyper offers a `--type-depth-limit` option to specify the maximum\nnumber of levels to include in type.\nFor example, with `--type-depth-limit=1`, a type inferred as `list[tuple[tuple[int, int]]]` would be emitted as `list[tuple]` instead.\n\n### Option overview\nBelow is the full list of options for the run command:\n\n```\n$ python3.12 -m righttyper run --help\nUsage: python -m righttyper run [OPTIONS] [SCRIPT] [ARGS]...\n\n  Runs a given script or module, collecting type information.\n\nOptions:\n  -m, --module MODULE             Run the given module instead of a script.\n  --all-files                     Process any files encountered, including\n                                  libraries (except for those specified in\n                                  --include-files)\n  --include-files PATTERN         Process only files matching the given\n                                  pattern.\n  --include-functions PATTERN     Only annotate functions matching the given\n                                  pattern.\n  --infer-shapes                  Produce tensor shape annotations (compatible\n                                  with jaxtyping).\n  --root DIRECTORY                Process only files under the given\n                                  directory.  If omitted, the script's\n                                  directory (or, for -m, the current\n                                  directory) is used.\n  --overwrite / --no-overwrite    Overwrite files with type information.\n                                  [default: no-overwrite]\n  --output-files / --no-output-files\n                                  Output annotated files (possibly\n                                  overwriting, if specified).  [default: no-\n                                  output-files]\n  --ignore-annotations            Ignore existing annotations and overwrite\n                                  with type information.\n  --only-update-annotations       Overwrite existing annotations but never add\n                                  new ones.\n  --generate-stubs                Generate stub files (.pyi).\n  --json-output                   Output inferences in JSON, instead of\n                                  writing righttyper.out.\n  --target-overhead FLOAT         Target overhead, as a percentage (e.g., 5).\n                                  [default: 5.0]\n  --use-multiprocessing / --no-use-multiprocessing\n                                  Whether to use multiprocessing.  [default:\n                                  use-multiprocessing]\n  --sampling / --no-sampling      Whether to sample calls or to use every one.\n                                  [default: sampling]\n  --replace-dict / --no-replace-dict\n                                  Whether to replace 'dict' to enable\n                                  efficient, statistically correct samples.\n                                  [default: no-replace-dict]\n  --container-sample-limit INTEGER\n                                  Number of container elements to sample.\n                                  [default: 1000]\n  --type-depth-limit [INTEGER|none]\n                                  Maximum depth (types within types) for\n                                  generic types; 'none' to disable.  [default:\n                                  none]\n  --python-version [3.9|3.10|3.11|3.12|3.13]\n                                  Python version for which to emit\n                                  annotations.  [default: 3.12]\n  --use-top-pct PCT               Only use the PCT% most common call traces.\n                                  [default: 80; 1\u003c=x\u003c=100]\n  --only-collect                  Rather than immediately process collect\n                                  data, save it to righttyper.rt. You can\n                                  later process using RightTyper's \"process\"\n                                  command.\n  --exclude-types TYPE_NAME       Exclude or replace with \"typing.Any\" types\n                                  whose full name starts with the given\n                                  string. Can be passed multiple times.\n                                  [default: pytest., _pytest., py.test.,\n                                  test_]\n  --no-exclude-types              Do not exclude types.\n  --resolve-mocks TYPE_NAME       Attempt to resolve mock types whose full\n                                  name starts with the given string to non-\n                                  test types. Can be passed multiple times.\n                                  [default: test_, unittest.mock.]\n  --no-resolve-mocks              Do not attempt to resolve mock types.\n  --use-typing-never / --no-use-typing-never\n                                  Whether to emit typing.Never.  [default:\n                                  use-typing-never]\n  --help                          Show this message and exit.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRightTyper%2FRightTyper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRightTyper%2FRightTyper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRightTyper%2FRightTyper/lists"}