{"id":19618583,"url":"https://github.com/cleder/crepr","last_synced_at":"2025-04-28T02:32:11.953Z","repository":{"id":204974890,"uuid":"713075251","full_name":"cleder/crepr","owner":"cleder","description":"Create a ❤️__repr__🤗️ for your python classes from the definition found in __init__","archived":false,"fork":false,"pushed_at":"2025-04-08T09:11:30.000Z","size":251,"stargazers_count":6,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-08T10:24:19.016Z","etag":null,"topics":["code-generation","hacktoberfest"],"latest_commit_sha":null,"homepage":"","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/cleder.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-11-01T19:37:42.000Z","updated_at":"2025-04-08T09:11:32.000Z","dependencies_parsed_at":"2024-05-06T17:51:50.719Z","dependency_job_id":"bbe8c211-fe0d-4ecc-845c-1b22be9221f1","html_url":"https://github.com/cleder/crepr","commit_stats":null,"previous_names":["cleder/crepr"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fcrepr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fcrepr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fcrepr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fcrepr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cleder","download_url":"https://codeload.github.com/cleder/crepr/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251238226,"owners_count":21557422,"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":["code-generation","hacktoberfest"],"created_at":"2024-11-11T11:09:57.094Z","updated_at":"2025-04-28T02:32:11.620Z","avatar_url":"https://github.com/cleder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crepr\n\nCreate a ``__repr__`` for your python classes.\n\n\n`crepr` is a Python script that takes a file name as a command-line argument, imports the specified module, and then adds or removes a `__repr__` method for each class defined in the module. It uses the definition found in the `__init__` method of the class to create a useful representation of the object.\nIt is pronounced /kɹeɪpr/, like 🇳🇿 crêpe.\n\nHave a look at the blog-post [Love Your Representation\n](https://dev.to/ldrscke/love-your-representation-27mm) for the rationale of this package.\n\n\n[![Tests](https://github.com/cleder/crepr/actions/workflows/run-all-tests.yml/badge.svg?branch=main)](https://github.com/cleder/crepr/actions/workflows/run-all-tests.yml)\n[![codecov](https://codecov.io/gh/cleder/crepr/graph/badge.svg?token=EGCcrWkpay)](https://codecov.io/gh/cleder/crepr)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)\n](https://github.com/pre-commit/pre-commit)\n[![MyPy](https://img.shields.io/badge/type_checker-mypy-blue)\n](http://mypy-lang.org/)\n[![Black](https://img.shields.io/badge/code_style-black-000000)\n](https://github.com/psf/black)\n[![MIT License](https://img.shields.io/pypi/l/crepr)](https://opensource.org/license/mit/)\n[![Python Version](https://img.shields.io/pypi/pyversions/crepr)](https://www.python.org/)\n[![PyPI - Version](https://img.shields.io/pypi/v/crepr)](https://pypi.org/project/crepr/)\n[![Status](https://img.shields.io/pypi/status/crepr)](https://pypi.org/project/crepr/)\n\n\n## Features\n\n* Automatically generates `__repr__` methods for all classes in a Python file\n* Uses the `__init__` method's arguments to create a meaningful representation\n* Can add or remove `__repr__` methods\n* Provides options to display the diff or apply changes directly to the file\n\n## Install\n\n```bash\npip install crepr\n```\n\n## Usage\n\nTo add a `__repr__` method to all classes in a file:\n\n```bash\ncrepr add \u003cfile_name\u003e [--kwarg-splat \"...\"] [--diff/--inline]\n```\n\nTo remove the `__repr__` method from all classes in a file:\n\n```bash\ncrepr remove \u003cfile_name\u003e [--diff/--inline]\n```\n\n### Options\n\n* `\u003cfile_name\u003e`: The name of the Python file to process.\n* `--kwarg-splat`: The string to use for the **kwargs splat (default: \"{}\").\n* `--diff`: Display the diff of the changes.\n* `--inline`: Apply the changes directly to the file.\n\n## Example\n\nGiven the file `tests/classes/kw_only_test.py` with the contents:\n\n```python\nclass KwOnly:\n    def __init__(self, name: str, *, age: int) -\u003e None:\n        self.name = name\n        self.age = age\n```\n\nThe command:\n\n```bash\n❯ crepr add tests/classes/kw_only_test.py\n```\n\nproduces\n\n```python\nclass KwOnly:\n    def __init__(self, name: str, *, age: int) -\u003e None:\n        self.name = name\n        self.age = age\n\n    def __repr__(self) -\u003e str:\n        \"\"\"Create a string (c)representation for KwOnly.\"\"\"\n        return (f'{self.__class__.__module__}.{self.__class__.__name__}('\n            f'name={self.name!r}, '\n            f'age={self.age!r}, '\n        ')')\n```\n\nThe `repr()` of an instance of this class will be:\n\n```python\n\u003e\u003e\u003e from tests.classes.kw_only_test import KwOnly\n\u003e\u003e\u003e kwo = KwOnly('Christian', age=25)\n\u003e\u003e\u003e kwo\ntests.classes.kw_only_test.KwOnly(name='Christian', age=25, )\n```\n\nApply the changes to the file with:\n\n```bash\n❯ crepr add tests/classes/kw_only_test.py --inline\n```\n\nGive your representations some love.\n\n❤️`.__repr__(self) -\u003e str:`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleder%2Fcrepr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleder%2Fcrepr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleder%2Fcrepr/lists"}