{"id":13733726,"url":"https://github.com/cyyc1/flake8-clean-block","last_synced_at":"2025-05-08T09:32:49.718Z","repository":{"id":60614812,"uuid":"544262971","full_name":"cyyc1/flake8-clean-block","owner":"cyyc1","description":"A flake8 plugin that enforces a blank line after if/for/while/with/try blocks in Python code","archived":false,"fork":false,"pushed_at":"2022-10-08T21:54:04.000Z","size":42,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T03:04:00.791Z","etag":null,"topics":["flake8-extension","flake8-extensions","flake8-plugin","flake8-plugins","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/flake8-clean-block/","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/cyyc1.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}},"created_at":"2022-10-02T03:29:16.000Z","updated_at":"2024-09-21T17:34:29.000Z","dependencies_parsed_at":"2022-10-02T04:50:22.196Z","dependency_job_id":null,"html_url":"https://github.com/cyyc1/flake8-clean-block","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyyc1%2Fflake8-clean-block","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyyc1%2Fflake8-clean-block/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyyc1%2Fflake8-clean-block/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyyc1%2Fflake8-clean-block/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyyc1","download_url":"https://codeload.github.com/cyyc1/flake8-clean-block/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252512819,"owners_count":21760082,"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":["flake8-extension","flake8-extensions","flake8-plugin","flake8-plugins","python"],"created_at":"2024-08-03T03:00:48.115Z","updated_at":"2025-05-08T09:32:49.468Z","avatar_url":"https://github.com/cyyc1.png","language":"Python","funding_links":[],"categories":["Clean code"],"sub_categories":[],"readme":"# flake8-clean-block\n\nThis is a [flake8](https://flake8.pycqa.org/en/latest/) plugin that enforces a blank line after `if`/`for`/`while`/`with`/`try` blocks in Python code.\n\n## Installation\n\n```bash\npip install flake8-clean-block\n```\n\n## Violation codes\n\nThere is one violation code that this plugin reports:\n\n| Code      | Description                                            |\n| --------- | ------------------------------------------------------ |\n| CLB100    | no blank line after the end of an indented block       |\n\n\n## Style examples\n\n### _Wrong_\n\nThis plugin considers the following styles wrong:\n\n```python\nfor i in range(5):\n    print(i)\nsome_var = 2\n```\n\n```python\nfor i in range(5):\n    print(i)\nif k == 2:\n    print(k)\nelse:\n    print(\"k\")\nfor j in range(5):\n    print(j)\n```\n\n```python\nfor i in range(5): a += i\nprint(a)\n```\n\n```python\nwith open('filename.txt', 'r') as fp:\n    content = fp.readlines()\nprint(content)\n```\n\n### _Correct_\n\nCorrespondingly, here are the correct styles, because they are easier to read and less error-prone:\n\n```python\nfor i in range(5):\n    print(i)\n\nsome_var = 2\n```\n\n```python\nfor i in range(5):\n    print(i)\n\nif k == 2:\n    print(k)\nelse:\n    print(\"k\")\n\nfor j in range(5):\n    print(j)\n```\n\n```python\nfor i in range(5): a += i\n\nprint(a)\n```\n\n```python\nwith open('filename.txt', 'r') as fp:\n    content = fp.readlines()\n\nprint(content)\n```\n\n## Rationale\n\nWhen two lines belonging to different indentation level are right next to each other, it's difficult to read.  Additionally, accidentally hitting the \"tab\" key on the outer line leads to subtle and hard-to-find bugs (and vice versa).\n\nTherefore, it's better that we add at least one blank line between lines of different indentation levels.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyyc1%2Fflake8-clean-block","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyyc1%2Fflake8-clean-block","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyyc1%2Fflake8-clean-block/lists"}