{"id":30133770,"url":"https://github.com/lftobs/penguin-lint","last_synced_at":"2025-08-10T20:11:52.512Z","repository":{"id":306304824,"uuid":"1024860335","full_name":"Lftobs/penguin-lint","owner":"Lftobs","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-24T18:05:37.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-24T23:48:57.140Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lftobs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-07-23T11:01:46.000Z","updated_at":"2025-07-24T18:05:40.000Z","dependencies_parsed_at":"2025-07-24T23:48:58.846Z","dependency_job_id":"77ebde64-0d6d-4cd2-a7b4-adba8a142807","html_url":"https://github.com/Lftobs/penguin-lint","commit_stats":null,"previous_names":["lftobs/penguin-lint"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Lftobs/penguin-lint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lftobs%2Fpenguin-lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lftobs%2Fpenguin-lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lftobs%2Fpenguin-lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lftobs%2Fpenguin-lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lftobs","download_url":"https://codeload.github.com/Lftobs/penguin-lint/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lftobs%2Fpenguin-lint/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269780617,"owners_count":24474686,"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-10T02:00:08.965Z","response_time":71,"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":[],"created_at":"2025-08-10T20:11:49.834Z","updated_at":"2025-08-10T20:11:52.481Z","avatar_url":"https://github.com/Lftobs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Penguin Lint\n\nPenguin Lint is a Python script that uses Abstract Syntax Trees (AST) to analyze and refactor Python code. It provides a simple framework for programmatically applying custom transformations to Python source code.\n\u003e created to undestand how ast works \n\n## Features\n\n- **Remove Print Statements**: Automatically removes `print()` calls from your code.\n- **Improve Formatting**: Inserts newlines to enforce a consistent style, such as adding blank lines before function and class definitions and breaking up long blocks of constant assignments.\n\n## How It Works\n\nThe script leverages Python's built-in `ast` module to parse source code into a tree structure. It then traverses this tree and modifies it using custom `ast.NodeTransformer` classes:\n\n- `PrintVisitor`: This transformer identifies and removes expressions that are `print()` calls.\n- `NewlineInserter`: This transformer adds blank lines to improve code readability. It inserts newlines before function and class definitions and after every four consecutive constant assignments.\n\nAfter applying these transformations, the script unparses the modified AST back into source code.\n\n## Usage\n\nTo use the script, simply run `main.py`:\n\n```bash\npython main.py\n```\n\nThe script contains a hardcoded example Python script. It will apply the transformations and print the refactored code to the console.\n\n### Example\n\n**Original Code:**\n\n```python\nimport requests\n\ndef fetch_data(url):\n    response = requests.get(url)\n    print(\"Data fetched successfully!\")\n    return response.json()\ndef main():\n    data = fetch_data(\"https://api.example.com/data\")\n    print(data)\n    return data\n\ndef hello():\n    print(\"Hello from main.py!\")\n    pass\ndef goodbye():\n    print(\"Goodbye from main.py!\")\n    pass\nlx = 10\nly = 20\npy = 30\npx = 40\nzt = 50\nci = 60\nko = 70\n```\n\n**Expected Refactored Code:**\n\n```python\nimport requests\n\ndef fetch_data(url):\n    response = requests.get(url)\n    return response.json()\n\ndef main():\n    data = fetch_data('https://api.example.com/data')\n    return data\n\ndef hello():\n    pass\n\ndef goodbye():\n    pass\nlx = 10\nly = 20\npy = 30\npx = 40\n\nzt = 50\nci = 60\nko = 70\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flftobs%2Fpenguin-lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flftobs%2Fpenguin-lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flftobs%2Fpenguin-lint/lists"}