{"id":20619884,"url":"https://github.com/mafda/python_best_practices","last_synced_at":"2025-04-15T12:13:09.027Z","repository":{"id":81393539,"uuid":"491709478","full_name":"mafda/python_best_practices","owner":"mafda","description":"How to make your code shine with isort, Black, Flake8, and Pylint. Guidelines and best practice suggestions on how to write Python code.","archived":false,"fork":false,"pushed_at":"2022-07-07T23:42:04.000Z","size":1214,"stargazers_count":34,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T12:12:36.336Z","etag":null,"topics":["best-practices","black","clean-code","flake8","formatter","good-practices","isort","linting","pep8","pep8-checker","pylint","python","python-best-practices","python-clean-code","styleguide"],"latest_commit_sha":null,"homepage":"","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/mafda.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}},"created_at":"2022-05-13T00:39:50.000Z","updated_at":"2025-02-20T05:23:14.000Z","dependencies_parsed_at":"2023-03-03T03:15:29.844Z","dependency_job_id":null,"html_url":"https://github.com/mafda/python_best_practices","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafda%2Fpython_best_practices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafda%2Fpython_best_practices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafda%2Fpython_best_practices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafda%2Fpython_best_practices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mafda","download_url":"https://codeload.github.com/mafda/python_best_practices/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249067779,"owners_count":21207396,"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":["best-practices","black","clean-code","flake8","formatter","good-practices","isort","linting","pep8","pep8-checker","pylint","python","python-best-practices","python-clean-code","styleguide"],"created_at":"2024-11-16T12:12:44.971Z","updated_at":"2025-04-15T12:13:09.013Z","avatar_url":"https://github.com/mafda.png","language":"Python","readme":"# Python Best Practices\n\n**How can you make your code shine with isort, Black, Flake8 and Pylint?** \n\nIn this repository, I would like to show some guidelines and best practice tips\non how to write Python code.\n\nWe can use a simple deck of programs to get our [code\nstyling](https://medium.com/semantixbr/how-to-make-your-code-shine-with-gitlab-ci-pipelines-48ade99192d1)\ndone. We can use **isort** for sorting the library imports (yes, imports have a\nsuggested order), we can check the existence of undesired artifacts using\n**Flake8** and **Pylint**, and we can keep the code within the same style using\n**Black**.\n\nThose tools can be configured to be [PEP8](https://peps.python.org/pep-0008/)\ncompliant. **PEP8 — Python Enhancement Proposal**, is a style guide that\nprovides guidelines and best practices suggestions on how to write Python code.\n\n## Python tools\n\n* Importing sorting with [isort](https://pycqa.github.io/isort/)\n* Formatting with [Black](https://github.com/psf/black) \n* Linting with [Flake8](https://flake8.pycqa.org/en/latest/) \n* Bug and quality checking with [Pylint](https://www.pylint.org/)\n\n## Project Setup\n\n### Clone this repository\n\n```shell\n(base)$: git clone git@github.com:mafda/python_best_practices.git\n(base)$: cd python_best_practices \n```\n\n### Configure environment\n\n- Create the conda environment\n\n```shell\n(base)$: conda env create -f environment.yml\n```\n\n- Activate the environment\n\n```shell\n(base)$: conda activate linear-regression\n```\n\n- And run\n\n```shell\n(linear-regression)$: sh pep8.sh\n```\n\n## Use these tools in your project and clean your code!\n\n```shell\n(base)$: conda env create -f environment-dev.yml\n(base)$: conda activate best-practices\n(best-practices)$: cd your-project\n```\n\n### isort\n\nYou could use `isort .` or `isort . --check-only`\n\n![isort](assets/isort.gif)\n\n### Black\n\nYou could use `black --line-length 79 .` or `black --line-length 79 --check .`\n\n![black](assets/black.gif)\n\n### Flake8\n\nYou could use `flake8 .`\n\n![flake8](assets/flake8.gif)\n\nFix errors:\n\n![flake8](assets/complete.gif)\n\n### PyLint\n\nYou could use `find . -type f -name \"*.py\" | xargs pylint`\n\n---\n\nmade with 💙 by [mafda](https://mafda.github.io/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafda%2Fpython_best_practices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmafda%2Fpython_best_practices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafda%2Fpython_best_practices/lists"}