{"id":15359973,"url":"https://github.com/henryiii/flake8-errmsg","last_synced_at":"2025-04-14T13:08:30.475Z","repository":{"id":58685903,"uuid":"533015266","full_name":"henryiii/flake8-errmsg","owner":"henryiii","description":"Flake8 checker for raw literals inside raises.","archived":false,"fork":false,"pushed_at":"2025-04-07T18:58:04.000Z","size":95,"stargazers_count":12,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T19:42:33.705Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/henryiii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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,"publiccode":null,"codemeta":null}},"created_at":"2022-09-05T18:26:10.000Z","updated_at":"2025-03-07T16:42:27.000Z","dependencies_parsed_at":"2023-12-23T00:49:25.322Z","dependency_job_id":"0a289ef6-1513-4e28-b78e-c660a40d6e09","html_url":"https://github.com/henryiii/flake8-errmsg","commit_stats":{"total_commits":51,"total_committers":6,"mean_commits":8.5,"dds":0.5882352941176471,"last_synced_commit":"c4e56e4d0dc29a430ec3d5e10e87e646e7353c50"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryiii%2Fflake8-errmsg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryiii%2Fflake8-errmsg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryiii%2Fflake8-errmsg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryiii%2Fflake8-errmsg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henryiii","download_url":"https://codeload.github.com/henryiii/flake8-errmsg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886318,"owners_count":21177643,"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-10-01T12:47:00.048Z","updated_at":"2025-04-14T13:08:30.198Z","avatar_url":"https://github.com/henryiii.png","language":"Python","readme":"# flake8-errmsg\n\n[![Actions Status][actions-badge]][actions-link]\n[![PyPI version][pypi-version]][pypi-link]\n[![PyPI platforms][pypi-platforms]][pypi-link]\n\n## Intro\n\nA checker for Flake8 that helps format nice error messages. The checks are:\n\n- **EM101**: Check for raw usage of a string literal in Exception raising.\n- **EM102**: Check for raw usage of an f-string literal in Exception raising.\n- **EM103**: Check for raw usage of `.format` on a string literal in Exception\n  raising.\n- **EM104**: Check for missing parentheses for built-in exceptions.\n- **EM105**: Check for missing message for built-in exceptions.\n\nThe issue is that Python includes the line with the raise in the default\ntraceback (and most other formatters, like Rich and IPython to too). That means\na user gets a message like this:\n\n```python\nsub = \"Some value\"\nraise RuntimeError(f\"{sub!r} is incorrect\")\n```\n\n```pytb\nTraceback (most recent call last):\n  File \"tmp.py\", line 2, in \u003cmodule\u003e\n    raise RuntimeError(f\"{sub!r} is incorrect\")\nRuntimeError: 'Some value' is incorrect\n```\n\nIf this is longer or more complex, the duplication can be quite confusing for a\nuser unaccustomed to reading tracebacks.\n\nWhile if you always assign to something like `msg`, then you get:\n\n```python\nsub = \"Some value\"\nmsg = f\"{sub!r} is incorrect\"\nraise RuntimeError(msg)\n```\n\n```pytb\nTraceback (most recent call last):\n  File \"tmp.py\", line 3, in \u003cmodule\u003e\n    raise RuntimeError(msg)\nRuntimeError: 'Some value' is incorrect\n```\n\nNow there's a simpler traceback and no double message. If you have a long\nmessage, this also often formats better when using Black, too.\n\nReminder: Libraries should produce tracebacks with custom error classes, and\napplications should print nice errors, usually _without_ a traceback, unless\nsomething _unexpected_ occurred. An app should not print a traceback for an\nerror that is known to be triggerable by a user.\n\n## Options\n\nThere is one option, `--errmsg-max-string-length`, which defaults to 0 but can\nbe set to a larger value. The check will ignore string literals shorter than\nthis length. This option is supported in configuration mode as well. This will\nonly affect string literals and not f-strings. This option is also supported\nwhen running directly, without Flake8.\n\n## Usage\n\nJust add this to your `.pre-commit-config.yaml` `flake8` check under\n`additional_dependencies`. If you use `extend-select`, you should need no other\nconfig.\n\nYou can also manually run this check (without Flake8's `noqa` filtering) via\nscript entry-point (`pipx run flake8-errmsg \u003cfiles\u003e`) or module entry-point\n(`python -m flake8_errmsg \u003cfiles\u003e` when installed).\n\n## FAQ\n\nQ: Why Python 3.10+ only? \u003cbr/\u003e A: This is a static checker and for developers.\nDevelopers and static checks should be on 3.10 already. And I was lazy and match\nstatements are fantastic for this sort of thing. And the AST module changed in\n3.8 anyway. Use [Ruff][] (which contains the checks from this plugin) if you\nneed to run on older versions.\n\nQ: What other sorts of checks are acceptable? \u003cbr/\u003e A: Things that help with\nnice errors. For example, maybe requiring `raise SystemExit(n)` over `sys.exit`,\n`exit`, etc. Possibly adding a check for `warnings.warn` without setting\n`stacklevel` to something (usually 2).\n\n\u003c!-- prettier-ignore-start --\u003e\n[actions-badge]:            https://github.com/henryiii/flake8-errmsg/workflows/CI/badge.svg\n[actions-link]:             https://github.com/henryiii/flake8-errmsg/actions\n[pypi-link]:                https://pypi.org/project/flake8-errmsg/\n[pypi-platforms]:           https://img.shields.io/pypi/pyversions/flake8-errmsg\n[pypi-version]:             https://img.shields.io/pypi/v/flake8-errmsg\n[ruff]:                      https://github.com/astral-sh/ruff\n\u003c!-- prettier-ignore-end --\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryiii%2Fflake8-errmsg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenryiii%2Fflake8-errmsg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryiii%2Fflake8-errmsg/lists"}