flake8-return


Nameflake8-return JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://pypi.org/project/flake8-return
SummaryFlake8 plugin that checks return values
upload_time2022-10-28 09:37:12
maintainer
docs_urlNone
authorAfonasev Evgeniy
requires_python>=3.6,<4.0
licenseMIT
keywords flake8 plugin return
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # flake8-return

[![pypi](https://badge.fury.io/py/flake8-return.svg)](https://pypi.org/project/flake8-return)
[![Python: 3.6+](https://img.shields.io/badge/Python-3.6+-blue.svg)](https://pypi.org/project/flake8-return)
[![Downloads](https://img.shields.io/pypi/dm/flake8-return.svg)](https://pypistats.org/packages/flake8-return)
[![Build Status](https://travis-ci.org/Afonasev/flake8-return.svg?branch=master)](https://travis-ci.org/Afonasev/flake8-return)
[![Code coverage](https://codecov.io/gh/afonasev/flake8-return/branch/master/graph/badge.svg)](https://codecov.io/gh/afonasev/flake8-return)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://en.wikipedia.org/wiki/MIT_License)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

Flake8 plugin that checks return values.

## Installation

```bash
pip install flake8-return
```

## Errors

* R501 do not explicitly return None in function if it is the only possible return value.

```python
def x(y):
    if not y:
        return
    return None  # error!
```

* R502 do not implicitly return None in function able to return non-None value.

```python
def x(y):
    if not y:
        return  # error!
    return 1
```

* R503 missing explicit return at the end of function able to return non-None value.

```python
def x(y):
    if not y:
        return 1
    # error!
```

* R504 unnecessary variable assignment before return statement.

```python
def x():
    a = 1
    # some code that not using `a`
    print('test')
    return a  # error!
```

* R505 unnecessary else after return statement.

```python
def x(y, z):
    if y:  # error!
        return 1
    else:
        return z
```

* R506 unnecessary else after raise statement.

```python
def x(y, z):
    if y:  # error!
        raise Exception(y)
    else:
        raise Exception(z)
```

* R507 unnecessary else after continue statement.

```python
def x(y, z):
    for i in y:
        if i < z:  # error!
            continue
        else:
            a = 0
```

* R508 unnecessary else after break statement.

```python
def x(y, z):
    for i in y:
        if i > z:  # error!
            break
        else:
            a = 0
```

Returns in asyncio coroutines also supported.

## For developers

### Show help

    make help

### Create venv and install deps

    make init

### Install git precommit hook

    make precommit

### Run linters, autoformat, tests etc

    make pretty lint test

### Bump new version

    make bump_major
    make bump_minor
    make bump_patch

## Change Log

Unreleased
-----

* ...

1.2.0 - 2022-10-28
-----

* Port no-else-break, no-else-continue, no-else-raise, no-else-return from pylint (#122) Calum Young
* PEP 621: Migrate more config to pyproject.toml (#123) Christian Clauss
* Fix/116/R504-try-except (#120) Calum Young
* Update ci (#119) Calum Young
* Fix/47/Update-R504-for-assignment-value (#117) Calum Young
* Upgrade GitHub Actions (#113) Christian Clauss
* Add a space to avoid a typo in R503 (#98) Christian Clauss
* GitHub Action to lint Python code (#97) Christian Clauss
* Typo fixes (#92) Aarni Koskela
* Create codeql-analysis.yml Afonasev Evgeniy
* Bump flake8-plugin-utils from 1.1.1 to 1.3.2 (#87) dependabot
* Bump mypy from 0.812 to 0.971 (#114) dependabot
* Bump pytest-cov from 3.0.0 to 4.0.0 (#124) dependabot
* Bump pytest-cov from 2.11.1 to 3.0.0 (#102) dependabot
* Bump pytest-mock from 3.6.0 to 3.6.1 (#91) dependabot
* Bump pytest from 6.2.4 to 6.2.5 (#99) dependabot
* Bump pylint from 2.8.2 to 2.10.2 (#100) dependabot
* Bump pytest from 6.2.3 to 6.2.4 (#86) dependabot

1.1.3 - 2021-05-05
-----

* Error clarifications (#77) Clément Robert
* fix linting (migrate to black 20.0b1) (#78) Clément Robert

1.1.2 - 2020-07-09
-----

* Make R504 visitors handle while loops (#56) Frank Tackitt
* Rename allows-prereleases to allow-prereleases (#55) Frank Tackitt
* Fix typo: → haven't (#24) Jon Dufresne

1.1.1 - 2019-09-21
-----

* fixed [#3](https://github.com/afonasev/flake8-return/issues/3) The R504 doesn't detect that the variable is modified in loop
* fixed [#4](https://github.com/afonasev/flake8-return/issues/4) False positive with R503 inside async with clause

1.1.0 - 2019-05-23
-----

* update flask_plugin_utils version to 1.0

1.0.0 - 2019-05-13
-----

* skip assign after unpacking while unnecessary assign checking "(x, y = my_obj)"

0.3.2 - 2019-04-01
-----

* allow "assert False" as last function return

0.3.1 - 2019-03-11
-----

* add pypi deploy into travis config
* add make bump_version command

0.3.0 - 2019-02-26
-----

* skip functions that consist only `return None`
* fix false positive when last return inner with statement
* add unnecessary assign error
* add support tuple in assign or return expressions
* add support asyncio coroutines

0.2.0 - 2019-02-21
-----

* fix explicit/implicit
* add flake8-plugin-utils as dependency
* allow raise as last function return
* allow no return as last line in while block
* fix if/elif/else cases

0.1.1 - 2019-02-10
-----

* fix error messages

0.1.0 - 2019-02-10
-----

* initial

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/flake8-return",
    "name": "flake8-return",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "flake8,plugin,return",
    "author": "Afonasev Evgeniy",
    "author_email": "ea.afonasev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/83/49/43ee60c21b61fbec8e86858b2dac7d11a9bdd9958fd7f59077387b6a7197/flake8-return-1.2.0.tar.gz",
    "platform": null,
    "description": "# flake8-return\n\n[![pypi](https://badge.fury.io/py/flake8-return.svg)](https://pypi.org/project/flake8-return)\n[![Python: 3.6+](https://img.shields.io/badge/Python-3.6+-blue.svg)](https://pypi.org/project/flake8-return)\n[![Downloads](https://img.shields.io/pypi/dm/flake8-return.svg)](https://pypistats.org/packages/flake8-return)\n[![Build Status](https://travis-ci.org/Afonasev/flake8-return.svg?branch=master)](https://travis-ci.org/Afonasev/flake8-return)\n[![Code coverage](https://codecov.io/gh/afonasev/flake8-return/branch/master/graph/badge.svg)](https://codecov.io/gh/afonasev/flake8-return)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://en.wikipedia.org/wiki/MIT_License)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\nFlake8 plugin that checks return values.\n\n## Installation\n\n```bash\npip install flake8-return\n```\n\n## Errors\n\n* R501 do not explicitly return None in function if it is the only possible return value.\n\n```python\ndef x(y):\n    if not y:\n        return\n    return None  # error!\n```\n\n* R502 do not implicitly return None in function able to return non-None value.\n\n```python\ndef x(y):\n    if not y:\n        return  # error!\n    return 1\n```\n\n* R503 missing explicit return at the end of function able to return non-None value.\n\n```python\ndef x(y):\n    if not y:\n        return 1\n    # error!\n```\n\n* R504 unnecessary variable assignment before return statement.\n\n```python\ndef x():\n    a = 1\n    # some code that not using `a`\n    print('test')\n    return a  # error!\n```\n\n* R505 unnecessary else after return statement.\n\n```python\ndef x(y, z):\n    if y:  # error!\n        return 1\n    else:\n        return z\n```\n\n* R506 unnecessary else after raise statement.\n\n```python\ndef x(y, z):\n    if y:  # error!\n        raise Exception(y)\n    else:\n        raise Exception(z)\n```\n\n* R507 unnecessary else after continue statement.\n\n```python\ndef x(y, z):\n    for i in y:\n        if i < z:  # error!\n            continue\n        else:\n            a = 0\n```\n\n* R508 unnecessary else after break statement.\n\n```python\ndef x(y, z):\n    for i in y:\n        if i > z:  # error!\n            break\n        else:\n            a = 0\n```\n\nReturns in asyncio coroutines also supported.\n\n## For developers\n\n### Show help\n\n    make help\n\n### Create venv and install deps\n\n    make init\n\n### Install git precommit hook\n\n    make precommit\n\n### Run linters, autoformat, tests etc\n\n    make pretty lint test\n\n### Bump new version\n\n    make bump_major\n    make bump_minor\n    make bump_patch\n\n## Change Log\n\nUnreleased\n-----\n\n* ...\n\n1.2.0 - 2022-10-28\n-----\n\n* Port no-else-break, no-else-continue, no-else-raise, no-else-return from pylint (#122) Calum Young\n* PEP 621: Migrate more config to pyproject.toml (#123) Christian Clauss\n* Fix/116/R504-try-except (#120) Calum Young\n* Update ci (#119) Calum Young\n* Fix/47/Update-R504-for-assignment-value (#117) Calum Young\n* Upgrade GitHub Actions (#113) Christian Clauss\n* Add a space to avoid a typo in R503 (#98) Christian Clauss\n* GitHub Action to lint Python code (#97) Christian Clauss\n* Typo fixes (#92) Aarni Koskela\n* Create codeql-analysis.yml Afonasev Evgeniy\n* Bump flake8-plugin-utils from 1.1.1 to 1.3.2 (#87) dependabot\n* Bump mypy from 0.812 to 0.971 (#114) dependabot\n* Bump pytest-cov from 3.0.0 to 4.0.0 (#124) dependabot\n* Bump pytest-cov from 2.11.1 to 3.0.0 (#102) dependabot\n* Bump pytest-mock from 3.6.0 to 3.6.1 (#91) dependabot\n* Bump pytest from 6.2.4 to 6.2.5 (#99) dependabot\n* Bump pylint from 2.8.2 to 2.10.2 (#100) dependabot\n* Bump pytest from 6.2.3 to 6.2.4 (#86) dependabot\n\n1.1.3 - 2021-05-05\n-----\n\n* Error clarifications (#77) Cl\u00e9ment Robert\n* fix linting (migrate to black 20.0b1) (#78) Cl\u00e9ment Robert\n\n1.1.2 - 2020-07-09\n-----\n\n* Make R504 visitors handle while loops (#56) Frank Tackitt\n* Rename allows-prereleases to allow-prereleases (#55) Frank Tackitt\n* Fix typo: \u2192 haven't (#24) Jon Dufresne\n\n1.1.1 - 2019-09-21\n-----\n\n* fixed [#3](https://github.com/afonasev/flake8-return/issues/3) The R504 doesn't detect that the variable is modified in loop\n* fixed [#4](https://github.com/afonasev/flake8-return/issues/4) False positive with R503 inside async with clause\n\n1.1.0 - 2019-05-23\n-----\n\n* update flask_plugin_utils version to 1.0\n\n1.0.0 - 2019-05-13\n-----\n\n* skip assign after unpacking while unnecessary assign checking \"(x, y = my_obj)\"\n\n0.3.2 - 2019-04-01\n-----\n\n* allow \"assert False\" as last function return\n\n0.3.1 - 2019-03-11\n-----\n\n* add pypi deploy into travis config\n* add make bump_version command\n\n0.3.0 - 2019-02-26\n-----\n\n* skip functions that consist only `return None`\n* fix false positive when last return inner with statement\n* add unnecessary assign error\n* add support tuple in assign or return expressions\n* add support asyncio coroutines\n\n0.2.0 - 2019-02-21\n-----\n\n* fix explicit/implicit\n* add flake8-plugin-utils as dependency\n* allow raise as last function return\n* allow no return as last line in while block\n* fix if/elif/else cases\n\n0.1.1 - 2019-02-10\n-----\n\n* fix error messages\n\n0.1.0 - 2019-02-10\n-----\n\n* initial\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Flake8 plugin that checks return values",
    "version": "1.2.0",
    "split_keywords": [
        "flake8",
        "plugin",
        "return"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "0ccab3e0b5d34a26579cfe9e2e703c0c",
                "sha256": "1f07af12954ed03ebe2c2aac2418f78b55374e9929d4956109664588f31582a1"
            },
            "downloads": -1,
            "filename": "flake8_return-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0ccab3e0b5d34a26579cfe9e2e703c0c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 10121,
            "upload_time": "2022-10-28T09:37:14",
            "upload_time_iso_8601": "2022-10-28T09:37:14.468591Z",
            "url": "https://files.pythonhosted.org/packages/f0/8c/6aece77ad2d0d68d8f6e8d5471fd06638de11df656db7d76de810815c437/flake8_return-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "77c8a509ea85c09a72924414a2baa81f",
                "sha256": "68dfa56582cd704febd02ad86dcf5df67e38e0836d62f1ceae7930d76d3dd955"
            },
            "downloads": -1,
            "filename": "flake8-return-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "77c8a509ea85c09a72924414a2baa81f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 10033,
            "upload_time": "2022-10-28T09:37:12",
            "upload_time_iso_8601": "2022-10-28T09:37:12.507606Z",
            "url": "https://files.pythonhosted.org/packages/83/49/43ee60c21b61fbec8e86858b2dac7d11a9bdd9958fd7f59077387b6a7197/flake8-return-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-28 09:37:12",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "flake8-return"
}
        
Elapsed time: 0.02250s