{"id":25869568,"url":"https://github.com/best-doctor/mr_proper","last_synced_at":"2025-10-04T20:32:05.340Z","repository":{"id":54519272,"uuid":"217902336","full_name":"best-doctor/mr_proper","owner":"best-doctor","description":"Static Python code analyzer, that tries to check if functions in code are pure or not and why.","archived":false,"fork":false,"pushed_at":"2023-04-11T09:05:36.000Z","size":256,"stargazers_count":19,"open_issues_count":7,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-21T10:51:47.732Z","etag":null,"topics":["pure-function","python","static-analyzer"],"latest_commit_sha":null,"homepage":null,"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/best-doctor.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":"2019-10-27T19:04:11.000Z","updated_at":"2024-08-12T08:14:05.000Z","dependencies_parsed_at":"2024-06-19T05:29:24.223Z","dependency_job_id":"ac593062-8f6f-406e-9eeb-719982565127","html_url":"https://github.com/best-doctor/mr_proper","commit_stats":{"total_commits":54,"total_committers":13,"mean_commits":4.153846153846154,"dds":0.5,"last_synced_commit":"bea2fb8f3e34f299ce7dbc016428883e7be68f62"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/best-doctor/mr_proper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/best-doctor%2Fmr_proper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/best-doctor%2Fmr_proper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/best-doctor%2Fmr_proper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/best-doctor%2Fmr_proper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/best-doctor","download_url":"https://codeload.github.com/best-doctor/mr_proper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/best-doctor%2Fmr_proper/sbom","scorecard":{"id":234855,"data":{"date":"2025-08-11","repo":{"name":"github.com/best-doctor/mr_proper","commit":"bea2fb8f3e34f299ce7dbc016428883e7be68f62"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":3,"reason":"Found 6/18 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/build_pr.yml:1","Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build_pr.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/build_pr.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build_pr.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/build_pr.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build_pr.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/build_pr.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/best-doctor/mr_proper/publish.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/build.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/build_pr.yml:21","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:33","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T05:26:47.958Z","repository_id":54519272,"created_at":"2025-08-17T05:26:47.958Z","updated_at":"2025-08-17T05:26:47.958Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278368629,"owners_count":25975476,"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-10-04T02:00:05.491Z","response_time":63,"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":["pure-function","python","static-analyzer"],"created_at":"2025-03-02T05:18:41.401Z","updated_at":"2025-10-04T20:32:05.282Z","avatar_url":"https://github.com/best-doctor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mr. Proper\n\n[![Build Status](https://travis-ci.org/best-doctor/mr_proper.svg?branch=master)](https://travis-ci.org/best-doctor/mr_proper)\n[![PyPI version](https://badge.fury.io/py/mr-proper.svg)](https://badge.fury.io/py/mr-proper)\n[![Maintainability](https://api.codeclimate.com/v1/badges/4b2234d95d5c4944e2e6/maintainability)](https://codeclimate.com/github/best-doctor/mr_proper/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/4b2234d95d5c4944e2e6/test_coverage)](https://codeclimate.com/github/best-doctor/mr_proper/test_coverage)\n\nStatic Python code analyzer, that tries to check if functions in code are\n[pure](https://en.wikipedia.org/wiki/Pure_function) or not and why.\n\n![Have fun with mr Clean](https://raw.githubusercontent.com/best-doctor/mr_proper/master/docs_img/mr_clean_sponge.jpg)\n\n*DISCLAIMER*: this library is very experimental and has a lot of edge cases.\nFunctions that mr. Proper marks as pure can be not pure, but they are\nusually cleaner than other functions.\n\n## Installation\n\n```bash\npip install mr_proper\n```\n\n## What mr. Proper check\n\n1. that function has no blacklisted calls (like `print`)\n   and blacklisted attributes access (like `smth.count`);\n1. that function not uses global objects (only local vars and function arguments);\n1. that function has al least one return;\n1. that function not mutates it's arguments;\n1. that function has no local imports;\n1. that function has no arguments of forbidden types (like ORM objects);\n1. that function not uses `self`, `class` or `super`;\n1. that function has calls of only pure functions.\n\nThis list is not enough to say that function is pure and some points\nare quite controversial, but it's a nice start.\n\n## Example\n\nConsole usage:\n\n```python\n    # test.py\n    def add_one(n: int) -\u003e int:\n        return n + 1\n\n    def print_amount_of_users(users_qs: QuerySet) -\u003e None:\n        print(f'Current amount of users is {users_qs.count()}')\n```\n\n```bash\n$ mr_propper test.py\nadd_one is pure!\nprint_amount_of_users is not pure because of:\n    it uses forbidden argument types (QuerySet)\n    it calls not pure functions (print)\n    it has no return\n```\n\nUsage inside Python code sample:\n\n```jupyterpython\n\u003e\u003e\u003e import ast\n\u003e\u003e\u003e from mr_propper.utils import is_function_pure\n\u003e\u003e\u003e funcdef = ast.parse('''\n    def add_one(n: int) -\u003e int:\n        return n + 1\n''').body[0]\n\u003e\u003e\u003e is_function_pure(funcdef)\nTrue\n\u003e\u003e\u003e is_function_pure(funcdef, with_errors=True)\n(True, [])\n```\n\n## Parameters\n\nCLI interface:\n\n- `filepath`: path to .py file to check (directories are not supported for now);\n- `--recursive`: require inner calls to be pure for function pureness.\n\n## Code prerequisites\n\n1. Python 3.7+;\n1. Functions are fully type-annotated;\n1. No dynamic calls (like `getattr(sender, 'send_' + message_type)(message)`).\n\n## Contributing\n\nWe would love you to contribute to our project. It's simple:\n\n1. Create an issue with bug you found or proposal you have.\n   Wait for approve from maintainer.\n1. Create a pull request. Make sure all checks are green.\n1. Fix review comments if any.\n1. Be awesome.\n\nHere are useful tips:\n\n- You can run all checks and tests with `make check`.\n  Please do it before TravisCI does.\n- We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/en/python_styleguide.md).\n- We respect [Django CoC](https://www.djangoproject.com/conduct/).\n  Make soft, not bullshit.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbest-doctor%2Fmr_proper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbest-doctor%2Fmr_proper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbest-doctor%2Fmr_proper/lists"}