{"id":18615706,"url":"https://github.com/jshwi/constcheck","last_synced_at":"2025-04-11T01:31:26.223Z","repository":{"id":37823889,"uuid":"479580980","full_name":"jshwi/constcheck","owner":"jshwi","description":"Check code for strings that could be constants","archived":false,"fork":false,"pushed_at":"2025-03-24T17:33:10.000Z","size":852,"stargazers_count":3,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T07:04:56.915Z","etag":null,"topics":["check","const","constant","dry","str"],"latest_commit_sha":null,"homepage":"https://constcheck.readthedocs.io","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/jshwi.png","metadata":{"files":{"readme":"README.rst","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,"publiccode":null,"codemeta":null}},"created_at":"2022-04-09T00:59:15.000Z","updated_at":"2024-08-09T02:10:46.000Z","dependencies_parsed_at":"2023-12-17T02:30:00.976Z","dependency_job_id":"e592aeec-0cdc-45a4-932d-53fd6bf3816c","html_url":"https://github.com/jshwi/constcheck","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshwi%2Fconstcheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshwi%2Fconstcheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshwi%2Fconstcheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshwi%2Fconstcheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jshwi","download_url":"https://codeload.github.com/jshwi/constcheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248325147,"owners_count":21084877,"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":["check","const","constant","dry","str"],"created_at":"2024-11-07T03:31:28.750Z","updated_at":"2025-04-11T01:31:21.213Z","avatar_url":"https://github.com/jshwi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"constcheck\n==========\n|License| |PyPI| |CI| |CodeQL| |pre-commit.ci status| |codecov.io| |readthedocs.org| |python3.8| |Black| |isort| |docformatter| |pylint| |Security Status| |Known Vulnerabilities| |constcheck|\n\n.. |License| image:: https://img.shields.io/badge/License-MIT-yellow.svg\n    :target: https://opensource.org/licenses/MIT\n    :alt: License\n.. |PyPI| image:: https://img.shields.io/pypi/v/constcheck\n    :target: https://pypi.org/project/constcheck/\n    :alt: PyPI\n.. |CI| image:: https://github.com/jshwi/constcheck/actions/workflows/build.yaml/badge.svg\n    :target: https://github.com/jshwi/constcheck/actions/workflows/build.yaml\n    :alt: Build\n.. |CodeQL| image:: https://github.com/jshwi/constcheck/actions/workflows/codeql-analysis.yml/badge.svg\n    :target: https://github.com/jshwi/constcheck/actions/workflows/codeql-analysis.yml\n    :alt: CodeQL\n.. |pre-commit.ci status| image:: https://results.pre-commit.ci/badge/github/jshwi/constcheck/master.svg\n   :target: https://results.pre-commit.ci/latest/github/jshwi/constcheck/master\n   :alt: pre-commit.ci status\n.. |codecov.io| image:: https://codecov.io/gh/jshwi/constcheck/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jshwi/constcheck\n    :alt: codecov.io\n.. |readthedocs.org| image:: https://readthedocs.org/projects/constcheck/badge/?version=latest\n    :target: https://constcheck.readthedocs.io/en/latest/?badge=latest\n    :alt: readthedocs.org\n.. |python3.8| image:: https://img.shields.io/badge/python-3.8-blue.svg\n    :target: https://www.python.org/downloads/release/python-380\n    :alt: python3.8\n.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Black\n.. |isort| image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336\n    :target: https://pycqa.github.io/isort/\n    :alt: isort\n.. |docformatter| image:: https://img.shields.io/badge/%20formatter-docformatter-fedcba.svg\n    :target: https://github.com/PyCQA/docformatter\n    :alt: docformatter\n.. |pylint| image:: https://img.shields.io/badge/linting-pylint-yellowgreen\n    :target: https://github.com/PyCQA/pylint\n    :alt: pylint\n.. |Security Status| image:: https://img.shields.io/badge/security-bandit-yellow.svg\n    :target: https://github.com/PyCQA/bandit\n    :alt: Security Status\n.. |Known Vulnerabilities| image:: https://snyk.io/test/github/jshwi/constcheck/badge.svg\n    :target: https://snyk.io/test/github/jshwi/constcheck/badge.svg\n    :alt: Known Vulnerabilities\n.. |constcheck| image:: https://snyk.io/advisor/python/docsig/badge.svg\n    :target: https://snyk.io/advisor/python/constcheck\n    :alt: constcheck\n\nCheck Python files for repeat use of strings\n--------------------------------------------\n\nEscape commas with \\\\\\\\ (\\\\ when enclosed in single quotes)\n\nDefaults can be configured in your pyproject.toml file\n\nInstallation\n------------\n\n.. code-block:: console\n\n    $ pip install constcheck\n\nUsage\n-----\n\nCommandline\n***********\n\n.. code-block:: console\n\n    usage: constcheck [-h] [-v] [-n] [-c INT] [-l INT] [-s STR] [-i LIST] [-I LIST]\n                                 [--ignore-from [FILE=LIST [FILE=LIST ...]]]\n                                 [path [path ...]]\n\n    Check Python files for repeat use of strings. Escape commas with \\\\. Defaults can be configured in\n    your pyproject.toml file.\n\n    positional arguments:\n      path                                       path(s) to check files for (default: .)\n\n    optional arguments:\n      -h, --help                                 show this help message and exit\n      -v, --version                              show program's version number and exit\n      -n, --no-ansi                              disable ansi output\n      -c INT, --count INT                        minimum number of repeat strings (default: 3)\n      -l INT, --length INT                       minimum length of repeat strings (default: 3)\n      -s STR, --string STR                       parse a string instead of a file\n      -i LIST, --ignore-strings LIST             comma separated list of strings to exclude\n      -I LIST, --ignore-files LIST               comma separated list of files to exclude\n      --ignore-from [FILE=LIST [FILE=LIST ...]]  comma separated list of strings to exclude from file\n\nAPI\n***\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from constcheck import constcheck\n\n.. code-block:: python\n\n    \u003e\u003e\u003e EXAMPLE = \"\"\"\n    ... STRING_1 = \"Hey\"\n    ... STRING_2 = \"Hey\"\n    ... STRING_3 = \"Hey\"\n    ... STRING_4 = \"Hello\"\n    ... STRING_5 = \"Hello\"\n    ... STRING_6 = \"Hello\"\n    ... STRING_7 = \"Hello\"\n    ... STRING_8 = \"Hello, world\"\n    ... STRING_9 = \"Hello, world\"\n    ... STRING_10 = \"Hello, world\"\n    ... STRING_11 = \"Hello, world\"\n    ... STRING_12 = \"Hello, world\"\n    ... \"\"\"\n\n.. code-block:: python\n\n    \u003e\u003e\u003e constcheck(string=EXAMPLE)\n    3   | Hey\n    4   | Hello\n    5   | Hello, world\n    \u003cBLANKLINE\u003e\n    1\n\nWith the ``count`` argument\n\n.. code-block:: python\n\n    \u003e\u003e\u003e constcheck(string=EXAMPLE, count=4)\n    4   | Hello\n    5   | Hello, world\n    \u003cBLANKLINE\u003e\n    1\n\nWith the ``length`` argument\n\n.. code-block:: python\n\n    \u003e\u003e\u003e constcheck(string=EXAMPLE, length=6)\n    5   | Hello, world\n    \u003cBLANKLINE\u003e\n    1\n\nWith the ``ignore_strings`` argument which accepts ``list`` of ``str`` objects\n\n.. code-block:: python\n\n    \u003e\u003e\u003e constcheck(string=EXAMPLE, ignore_strings=[\"Hello, world\", \"Hello\"])\n    3   | Hey\n    \u003cBLANKLINE\u003e\n    1\n\nConfig\n******\n\nAll keyword arguments available to ``constcheck()`` can be configured in the pyproject.toml file\n\n.. code-block:: toml\n\n    [tool.constcheck]\n    path = \".\"\n    count = 3\n    length = 3\n    ignore_strings = [\"Hello\", \"Hello, world\"]\n    ignore_files = [\"tests/__init__.py\"]\n    filter = false\n    no_color = false\n\n    [tool.constcheck.ignore_from]\n    \"tests/__init__.py\" = [\"Hello, world\"]\n\npre-commit\n##########\n\n`constcheck` can be used as a `pre-commit \u003chttps://pre-commit.com\u003e`_ hook\n\nIt can be added to your .pre-commit-config.yaml as follows:\n\n.. code-block:: yaml\n\n    repos:\n      - repo: https://github.com/jshwi/constcheck\n        rev: v0.7.0\n        hooks:\n          - id: constcheck\n            args:\n              - \"--count=3\"\n              - \"--length=3\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshwi%2Fconstcheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjshwi%2Fconstcheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshwi%2Fconstcheck/lists"}