flake8-ruff


Nameflake8-ruff JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/tjkuson/flake8-ruff
SummaryA Flake8 plugin that implements miscellaneous checks from Ruff.
upload_time2024-02-18 01:05:47
maintainer
docs_urlNone
authorTom Kuson
requires_python>=3.9
licenseMIT
keywords flake8 ruff
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # flake8-ruff

[![image](https://img.shields.io/pypi/v/flake8-ruff.svg)](https://pypi.python.org/pypi/flake8-ruff)

A Flake8 plugin that implements miscellaneous checks from [Ruff](https://github.com/astral-sh/ruff).

Specifically, this plugin implements checks that are under the `RUF` category
(the rules that do not have a direct equivalent in Flake8).

## Requirements

Python 3.9 to 3.12 is supported.

## Installation

Install from PyPI. For example,

```bash
pip install flake8-ruff
```

Then follow the instructions on the [Flake8 documentation](https://flake8.pycqa.org/en/latest/index.html)
to enable the plugin.

## Checks

### RUF010 Use explicit conversion flag

Checks for `str()`, `repr()`, and `ascii()` as explicit conversions within
f-strings.

For example, replace

```python
f"{ascii(foo)}, {repr(bar)}, {str(baz)}"
```

with

```python
f"{foo!a}, {bar!r}, {baz!s}"
```

or, often (such as where `__str__` and `__format__` are equivalent),

```python
f"{foo!a}, {bar!r}, {baz}"
```

Derived from [explicit-f-string-type-conversion (RUF010)](https://docs.astral.sh/ruff/rules/explicit-f-string-type-conversion/).

### RUF018 Avoid assignment expressions in `assert` statements

Checks for named assignment expressions in `assert` statements. When Python is
run with the `-O` option, the `assert` statement is ignored, and the assignment
expression is not executed. This can lead to unexpected behavior.

For example, replace

```python
assert (result := foo()) is not None
```

with

```python
result = foo()
assert result is not None
```

Derived from [assignment-in-assert (RUF018)](https://docs.astral.sh/ruff/rules/assignment-in-assert/).

### RUF020 `typing.Never | T` is equivalent to `T`

Checks for `typing.Never` and `typing.NoReturn` in union types, which is
redundant.

For example, replace

```python
typing.Never | int | None
```

with

```python
int | None
```

Derived from [never-union (RUF020)](https://docs.astral.sh/ruff/rules/never-union/).

### RUF025 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead

Checks for dict comprehensions that create a dictionary from an iterable with a
constant value. Instead, use `dict.fromkeys`, which is more efficient.

For example, replace

```python
{key: 0 for key in keys}
```

with

```python
dict.fromkeys(keys, 0)
```

and

```python
{key: None for key in keys}
```

with

```python
dict.fromkeys(keys)
```

Derived from [unnecessary-dict-comprehension-for-iterable (RUF025)](https://docs.astral.sh/ruff/rules/unnecessary-dict-comprehension-for-iterable/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tjkuson/flake8-ruff",
    "name": "flake8-ruff",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "flake8,ruff",
    "author": "Tom Kuson",
    "author_email": "mail@tjkuson.me",
    "download_url": "https://files.pythonhosted.org/packages/cd/98/96f94f55cd067c51cfdf762f14ba547eff4fd2bc9688f5443ca16873ab8a/flake8_ruff-0.3.0.tar.gz",
    "platform": null,
    "description": "# flake8-ruff\n\n[![image](https://img.shields.io/pypi/v/flake8-ruff.svg)](https://pypi.python.org/pypi/flake8-ruff)\n\nA Flake8 plugin that implements miscellaneous checks from [Ruff](https://github.com/astral-sh/ruff).\n\nSpecifically, this plugin implements checks that are under the `RUF` category\n(the rules that do not have a direct equivalent in Flake8).\n\n## Requirements\n\nPython 3.9 to 3.12 is supported.\n\n## Installation\n\nInstall from PyPI. For example,\n\n```bash\npip install flake8-ruff\n```\n\nThen follow the instructions on the [Flake8 documentation](https://flake8.pycqa.org/en/latest/index.html)\nto enable the plugin.\n\n## Checks\n\n### RUF010 Use explicit conversion flag\n\nChecks for `str()`, `repr()`, and `ascii()` as explicit conversions within\nf-strings.\n\nFor example, replace\n\n```python\nf\"{ascii(foo)}, {repr(bar)}, {str(baz)}\"\n```\n\nwith\n\n```python\nf\"{foo!a}, {bar!r}, {baz!s}\"\n```\n\nor, often (such as where `__str__` and `__format__` are equivalent),\n\n```python\nf\"{foo!a}, {bar!r}, {baz}\"\n```\n\nDerived from [explicit-f-string-type-conversion (RUF010)](https://docs.astral.sh/ruff/rules/explicit-f-string-type-conversion/).\n\n### RUF018 Avoid assignment expressions in `assert` statements\n\nChecks for named assignment expressions in `assert` statements. When Python is\nrun with the `-O` option, the `assert` statement is ignored, and the assignment\nexpression is not executed. This can lead to unexpected behavior.\n\nFor example, replace\n\n```python\nassert (result := foo()) is not None\n```\n\nwith\n\n```python\nresult = foo()\nassert result is not None\n```\n\nDerived from [assignment-in-assert (RUF018)](https://docs.astral.sh/ruff/rules/assignment-in-assert/).\n\n### RUF020 `typing.Never | T` is equivalent to `T`\n\nChecks for `typing.Never` and `typing.NoReturn` in union types, which is\nredundant.\n\nFor example, replace\n\n```python\ntyping.Never | int | None\n```\n\nwith\n\n```python\nint | None\n```\n\nDerived from [never-union (RUF020)](https://docs.astral.sh/ruff/rules/never-union/).\n\n### RUF025 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead\n\nChecks for dict comprehensions that create a dictionary from an iterable with a\nconstant value. Instead, use `dict.fromkeys`, which is more efficient.\n\nFor example, replace\n\n```python\n{key: 0 for key in keys}\n```\n\nwith\n\n```python\ndict.fromkeys(keys, 0)\n```\n\nand\n\n```python\n{key: None for key in keys}\n```\n\nwith\n\n```python\ndict.fromkeys(keys)\n```\n\nDerived from [unnecessary-dict-comprehension-for-iterable (RUF025)](https://docs.astral.sh/ruff/rules/unnecessary-dict-comprehension-for-iterable/).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Flake8 plugin that implements miscellaneous checks from Ruff.",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/tjkuson/flake8-ruff",
        "Repository": "https://github.com/tjkuson/flake8-ruff"
    },
    "split_keywords": [
        "flake8",
        "ruff"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a8337392193b3224b2003f3dd93226241e7ac2a08e4d0d3190d765a00c6a78c",
                "md5": "6c85b5f8c032e42fa0cf756f16458a7e",
                "sha256": "00c3967c84ceac7702a2917743fe7abc1bd302013b2e45518d867d6482d0034b"
            },
            "downloads": -1,
            "filename": "flake8_ruff-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6c85b5f8c032e42fa0cf756f16458a7e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 3617,
            "upload_time": "2024-02-18T01:05:46",
            "upload_time_iso_8601": "2024-02-18T01:05:46.384531Z",
            "url": "https://files.pythonhosted.org/packages/9a/83/37392193b3224b2003f3dd93226241e7ac2a08e4d0d3190d765a00c6a78c/flake8_ruff-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd9896f94f55cd067c51cfdf762f14ba547eff4fd2bc9688f5443ca16873ab8a",
                "md5": "7550bf9f44010763e89d419a9e41f13c",
                "sha256": "e45ac429d68f683228c0851a9363c191e8f67c2ea3af33f798c465f55aee0940"
            },
            "downloads": -1,
            "filename": "flake8_ruff-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7550bf9f44010763e89d419a9e41f13c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 3211,
            "upload_time": "2024-02-18T01:05:47",
            "upload_time_iso_8601": "2024-02-18T01:05:47.884967Z",
            "url": "https://files.pythonhosted.org/packages/cd/98/96f94f55cd067c51cfdf762f14ba547eff4fd2bc9688f5443ca16873ab8a/flake8_ruff-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-18 01:05:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tjkuson",
    "github_project": "flake8-ruff",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flake8-ruff"
}
        
Elapsed time: 0.18376s