{"id":13800844,"url":"https://github.com/hauntsaninja/no_implicit_optional","last_synced_at":"2025-04-10T00:18:28.329Z","repository":{"id":58831788,"uuid":"533597702","full_name":"hauntsaninja/no_implicit_optional","owner":"hauntsaninja","description":"A codemod to make your implicit optional type hints PEP 484 compliant.","archived":false,"fork":false,"pushed_at":"2023-11-25T23:21:36.000Z","size":11,"stargazers_count":90,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T00:18:23.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hauntsaninja.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-09-07T04:00:26.000Z","updated_at":"2025-03-07T04:03:09.000Z","dependencies_parsed_at":"2024-04-11T14:03:23.693Z","dependency_job_id":"e917b046-4945-484e-9c9c-b5f977d7d8fc","html_url":"https://github.com/hauntsaninja/no_implicit_optional","commit_stats":{"total_commits":15,"total_committers":3,"mean_commits":5.0,"dds":0.2666666666666667,"last_synced_commit":"f76d963cd7f52a6de55b442287517bb8966e9fb9"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauntsaninja%2Fno_implicit_optional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauntsaninja%2Fno_implicit_optional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauntsaninja%2Fno_implicit_optional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hauntsaninja%2Fno_implicit_optional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hauntsaninja","download_url":"https://codeload.github.com/hauntsaninja/no_implicit_optional/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131318,"owners_count":21052820,"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","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":[],"created_at":"2024-08-04T00:01:16.865Z","updated_at":"2025-04-10T00:18:28.287Z","avatar_url":"https://github.com/hauntsaninja.png","language":"Python","readme":"# no_implicit_optional\n\nA codemod to make your implicit optional type hints PEP 484 compliant.\n\n## Running\n\nThis tool will make changes to your code. Make sure you're using version control, like `git`.\n\n```bash\npipx run no_implicit_optional \u003cpath\u003e\n```\n\nAlternatively, and perhaps more familiarly:\n```bash\npip install no_implicit_optional\nno_implicit_optional \u003cpath\u003e\n```\n\nTo make this tool use PEP 604 `X | None` syntax instead of `Optional[X]`, use the\n`--use-union-or` flag. Note that this syntax is only fully supported on Python 3.10 and newer.\n\n## What's going on?\n\nBy default, mypy 0.982 and earlier allowed eliding `Optional` for arguments with default values of\n`None`. From experience, this was found to be a source of confusion and bugs.\n\nIn 2018, PEP 484 was updated to require the explicit use of `Optional` (or a `Union` with `None`)\nand mypy enforces this when run using `mypy --strict` or `mypy --no-implicit-optional`.\nSimilarly, other type checkers like pyright do not recognise implicit `Optional` at all.\n\nHere's what this looks like in practice:\n\n```python\ndef bad(x: int = None):\n    ...\n\ndef good(x: Optional[int] = None):\n    ...\n\ndef good(x: Union[int, None] = None):\n    ...\n\n# PEP 604 syntax, requires Python 3.10+ or `from __future__ import annotations`\ndef good(x: int | None = None):\n    ...\n```\n\nAnyway, mypy is changing its default to match PEP 484 and disallow implicit `Optional`. In order\nto make the transition easier, this tool will try to automatically fix your code, building off\nof [libcst](https://libcst.readthedocs.io/en/latest/) to do so.\n\nAlso refer to:\n- https://peps.python.org/pep-0484/#union-types\n- https://github.com/python/mypy/issues/9091\n- https://github.com/python/mypy/pull/13401\n\n\n## I don't want to change my code\n\nUse `mypy --implicit-optional` or set `implicit_optional = True` in your mypy config.\n","funding_links":[],"categories":["Tools"],"sub_categories":["Helper tools to add annotations to existing code"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhauntsaninja%2Fno_implicit_optional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhauntsaninja%2Fno_implicit_optional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhauntsaninja%2Fno_implicit_optional/lists"}