Name | ondivi JSON |
Version |
0.6.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-11-05 19:26:07 |
maintainer | None |
docs_url | None |
author | Almaz Ilaletdinov |
requires_python | <4.0,>=3.9 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Ondivi (Only diff violations)
[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)
[![PyPI version](https://badge.fury.io/py/ondivi.svg)](https://badge.fury.io/py/ondivi)
![CI status](https://github.com/blablatdinov/ondivi/actions/workflows/pr-check.yml/badge.svg?branch=master)
[![Lines of code](https://tokei.rs/b1/github/blablatdinov/ondivi)](https://github.com/XAMPPRocky/tokei_rs)
[![Hits-of-Code](https://hitsofcode.com/github/blablatdinov/ondivi)](https://hitsofcode.com/github/blablatdinov/quranbot-aiogram/view)
This is a simple Python script designed to filter coding violations (likely identified by a static analyzer) for only the lines that have been changed in a Git repository.
This tool works with any linter or static code analyzer, including but not limited to:
- [Flake8](https://github.com/PyCQA/flake8)
- [Ruff](https://github.com/astral-sh/ruff)
- [Pylint](https://github.com/pylint-dev/pylint)
- [Mypy](https://github.com/python/mypy)
- [Eslint](https://github.com/eslint/eslint)
- [Rubocop](https://github.com/rubocop/rubocop)
- [Stylelint](https://github.com/stylelint/stylelint)
## Prerequisites:
- [Python](https://python.org) 3.9 or higher
- [Git](https://git-scm.com/)
## Installation
```bash
pip install ondivi
```
## Usage
Ensure you are in the root directory of your Git repository.
Run the script:
```bash
flake8 script.py | ondivi
# with ruff:
ruff check file.py --output-format=concise | ondivi
```
or:
```bash
flake8 script.py > violations.txt
ondivi --fromfile=violations.txt
```
```
$ ondivi --help
Usage: ondivi [OPTIONS]
Ondivi (Only diff violations).
Python script filtering coding violations, identified by static analysis,
only for changed lines in a Git repo. Usage example:
flake8 script.py | ondivi
Options:
--baseline TEXT Commit or branch which will contain legacy code. Program
filter out violations on baseline (default: "master")
--fromfile TEXT Path to file with violations. Expected "utf-8" encoding
--format TEXT Template for parsing linter messages. The template should
include the following named parts:
{filename} The name of the file with the error/warning
{line_num} The line number with the error/warning
(integer)
Example usage:
--format "{filename}:{line_num:d}{other}"
In this example, the linter message
"src/app_types/listable.py:23:1: UP035 Import from
collections.abc instead: Sequence"
will be recognized and parsed into the following
components:
- filename: "src/app_types/listable.py"
- line_num: 23
- other: :1: "UP035 Import from collections.abc instead:
Sequence"
Ensure that the template matches the format of the
messages generated by your linter.
(default: "{filename}:{line_num:d}{other}")
--only-violations Show only violations
--help Show this message and exit.
```
## How it works
The script parses the Git diff output to identify the changed lines in each file.
It then filters the given coding violations to include only those violations that correspond to the changed lines.
[flakeheaven](https://github.com/flakeheaven/flakeheaven) and [flakehell](https://github.com/flakehell/flakehell)
are not supported because they rely on internal flake8 API, which can lead to compatibility issues as flake8
evolves. In contrast, ondivi uses only the text output of violations and the state of Git repository, making
it more robust and easier to maintain.
Flake8 on file:
```bash
$ flake8 file.py
file.py:3:1: E302 expected 2 blank lines, found 1
file.py:9:1: E302 expected 2 blank lines, found 1
file.py:10:121: E501 line too long (123 > 120 characters)
file.py:14:1: E305 expected 2 blank lines after class or function definition, found 1
```
Example of changes:
```diff
from dataclasses import dataclass
@dataclass
class User(object):
name: str
age: int
def greet(user: User):
print('Long string in initial commit ################################################################################')
print(f'Hello, {user.name}!')
+ print('Long string in new commit ################################################################################')
if __name__ == '__main__':
greet(User(345, 23))
+ greet(User('Bob', '23'))
```
By git diff we see, that two new lines were appended (12 and 16):
Ondivi filters out violations and shows only one for line 12:
```bash
$ flake8 script.py | ondivi
file.py:12:80: E501 line too long (119 > 79 characters)
```
## License
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "ondivi",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Almaz Ilaletdinov",
"author_email": "a.ilaletdinov@yandex.ru",
"download_url": "https://files.pythonhosted.org/packages/d9/00/c2b6b20ffce2b88e1caa93d5c8275f367ff7bcc3b800a23820abeb659ffe/ondivi-0.6.0.tar.gz",
"platform": null,
"description": "# Ondivi (Only diff violations)\n\n[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)\n[![PyPI version](https://badge.fury.io/py/ondivi.svg)](https://badge.fury.io/py/ondivi)\n![CI status](https://github.com/blablatdinov/ondivi/actions/workflows/pr-check.yml/badge.svg?branch=master)\n[![Lines of code](https://tokei.rs/b1/github/blablatdinov/ondivi)](https://github.com/XAMPPRocky/tokei_rs)\n[![Hits-of-Code](https://hitsofcode.com/github/blablatdinov/ondivi)](https://hitsofcode.com/github/blablatdinov/quranbot-aiogram/view)\n\nThis is a simple Python script designed to filter coding violations (likely identified by a static analyzer) for only the lines that have been changed in a Git repository.\n\nThis tool works with any linter or static code analyzer, including but not limited to:\n\n- [Flake8](https://github.com/PyCQA/flake8)\n- [Ruff](https://github.com/astral-sh/ruff)\n- [Pylint](https://github.com/pylint-dev/pylint)\n- [Mypy](https://github.com/python/mypy)\n- [Eslint](https://github.com/eslint/eslint)\n- [Rubocop](https://github.com/rubocop/rubocop)\n- [Stylelint](https://github.com/stylelint/stylelint)\n\n## Prerequisites:\n\n- [Python](https://python.org) 3.9 or higher\n- [Git](https://git-scm.com/)\n\n## Installation\n\n```bash\npip install ondivi\n```\n\n## Usage\n\nEnsure you are in the root directory of your Git repository.\n\nRun the script:\n\n```bash\nflake8 script.py | ondivi\n# with ruff:\nruff check file.py --output-format=concise | ondivi\n```\n\nor:\n\n```bash\nflake8 script.py > violations.txt\nondivi --fromfile=violations.txt\n```\n\n```\n$ ondivi --help\nUsage: ondivi [OPTIONS]\n\n Ondivi (Only diff violations).\n\n Python script filtering coding violations, identified by static analysis,\n only for changed lines in a Git repo. Usage example:\n\n flake8 script.py | ondivi\n\nOptions:\n --baseline TEXT Commit or branch which will contain legacy code. Program\n filter out violations on baseline (default: \"master\")\n --fromfile TEXT Path to file with violations. Expected \"utf-8\" encoding\n --format TEXT Template for parsing linter messages. The template should\n include the following named parts:\n\n {filename} The name of the file with the error/warning\n {line_num} The line number with the error/warning\n (integer)\n\n Example usage:\n\n --format \"{filename}:{line_num:d}{other}\"\n\n In this example, the linter message\n\n \"src/app_types/listable.py:23:1: UP035 Import from\n collections.abc instead: Sequence\"\n\n will be recognized and parsed into the following\n components:\n\n - filename: \"src/app_types/listable.py\"\n - line_num: 23\n - other: :1: \"UP035 Import from collections.abc instead:\n Sequence\"\n\n Ensure that the template matches the format of the\n messages generated by your linter.\n (default: \"{filename}:{line_num:d}{other}\")\n --only-violations Show only violations\n --help Show this message and exit.\n```\n\n## How it works\n\nThe script parses the Git diff output to identify the changed lines in each file.\n\nIt then filters the given coding violations to include only those violations that correspond to the changed lines.\n\n[flakeheaven](https://github.com/flakeheaven/flakeheaven) and [flakehell](https://github.com/flakehell/flakehell)\nare not supported because they rely on internal flake8 API, which can lead to compatibility issues as flake8\nevolves. In contrast, ondivi uses only the text output of violations and the state of Git repository, making\nit more robust and easier to maintain.\n\nFlake8 on file:\n\n```bash\n$ flake8 file.py\nfile.py:3:1: E302 expected 2 blank lines, found 1\nfile.py:9:1: E302 expected 2 blank lines, found 1\nfile.py:10:121: E501 line too long (123 > 120 characters)\nfile.py:14:1: E305 expected 2 blank lines after class or function definition, found 1\n```\n\nExample of changes:\n\n```diff\n from dataclasses import dataclass\n\n @dataclass\n class User(object):\n\n name: str\n age: int\n\n def greet(user: User):\n print('Long string in initial commit ################################################################################')\n print(f'Hello, {user.name}!')\n+ print('Long string in new commit ################################################################################')\n\n if __name__ == '__main__':\n greet(User(345, 23))\n+ greet(User('Bob', '23'))\n```\n\nBy git diff we see, that two new lines were appended (12 and 16):\n\nOndivi filters out violations and shows only one for line 12:\n\n```bash\n$ flake8 script.py | ondivi\nfile.py:12:80: E501 line too long (119 > 79 characters)\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.6.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f8a6afefd3346f069d8cc3dac27655f7e9a1d1c7fce70b53ff6797b5287057d7",
"md5": "0a9f0026b2461fe504c4cb5ad17acf67",
"sha256": "f0f6d7b0f04e503356bbe92ef3013918ef96a182b9c719105668a72cf446024d"
},
"downloads": -1,
"filename": "ondivi-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0a9f0026b2461fe504c4cb5ad17acf67",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 13023,
"upload_time": "2024-11-05T19:26:07",
"upload_time_iso_8601": "2024-11-05T19:26:07.004008Z",
"url": "https://files.pythonhosted.org/packages/f8/a6/afefd3346f069d8cc3dac27655f7e9a1d1c7fce70b53ff6797b5287057d7/ondivi-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d900c2b6b20ffce2b88e1caa93d5c8275f367ff7bcc3b800a23820abeb659ffe",
"md5": "35468b0e668283fe50e02c24de509f94",
"sha256": "4ada3de926ff3263decd62e24d661cac9b835decbdad27eb8cc83078264b4170"
},
"downloads": -1,
"filename": "ondivi-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "35468b0e668283fe50e02c24de509f94",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 16012,
"upload_time": "2024-11-05T19:26:07",
"upload_time_iso_8601": "2024-11-05T19:26:07.987182Z",
"url": "https://files.pythonhosted.org/packages/d9/00/c2b6b20ffce2b88e1caa93d5c8275f367ff7bcc3b800a23820abeb659ffe/ondivi-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-05 19:26:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ondivi"
}