diff options
Diffstat (limited to 'python-tryceratops.spec')
-rw-r--r-- | python-tryceratops.spec | 357 |
1 files changed, 357 insertions, 0 deletions
diff --git a/python-tryceratops.spec b/python-tryceratops.spec new file mode 100644 index 0000000..a945dc3 --- /dev/null +++ b/python-tryceratops.spec @@ -0,0 +1,357 @@ +%global _empty_manifest_terminate_build 0 +Name: python-tryceratops +Version: 2.0.0 +Release: 1 +Summary: Prevent Exception Handling AntiPatterns +License: MIT +URL: https://github.com/guilatrova/tryceratops +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/0f/44/06781b5706ae3c685bc09fd63528151cf58ce36ee23a120153d07bc681ca/tryceratops-2.0.0.tar.gz +BuildArch: noarch + +Requires: python3-click +Requires: python3-rich +Requires: python3-toml + +%description +## Installation and usage +### Installation +``` +pip install tryceratops +``` +OR +``` +poetry add -D tryceratops +``` +### Usage +``` +tryceratops [filename or dir...] +``` +You can enable experimental analyzers by running: +``` +tryceratops --experimental [filename or dir...] +``` +You can ignore specific violations by using: `--ignore TRYXXX` repeatedly: +``` +tryceratops --ignore TRY201 --ignore TRY202 [filename or dir...] +``` +You can exclude dirs by using: `--exclude dir/path` repeatedly: +``` +tryceratops --exclude tests --exclude .venv [filename or dir...] +``` +You can also autofix some violations: +``` +tryceratops --autofix [filename or dir...] +``` + +### [`flake8`](https://github.com/PyCQA/flake8) Plugin +🦖 Tryceratops is also a plugin for `flake8`, so you can: +``` +❯ flake8 --select TRY src/tests/samples/violations/call_raise_vanilla.py +src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY002 Create your own exception +src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY003 Avoid specifying long messages outside the exception class +src/tests/samples/violations/call_raise_vanilla.py:21:9: TRY201 Simply use 'raise' without specifying exception object again +``` +## Violations +All violations and its descriptions can be found in [docs](https://github.com/guilatrova/tryceratops/tree/main/docs/violations). +### Autofix support +So far, autofix only supports violations: [TRY200](docs/violations/TRY200.md), [TRY201](docs/violations/TRY201.md), and [TRY400](docs/violations/TRY400.md). +### Ignoring violations +If you want to ignore a violation in a specific file, you can either: +- Add a comment with `noqa` to the top of the file you want to ignore +- Add a comment with `noqa` to the line you want to ignore +- Add a comment with `noqa: CODE` to the line you want to ignore a specific violation +Example: +```py +def verbose_reraise_1(): + try: + a = 1 + except Exception as ex: + raise ex # noqa: TRY202 +``` +### Configuration +You can set up a `pyproject.toml` file to set rules. +This is useful to avoid reusing the same CLI flags over and over again and helps to define the structure of your project. +Example: +```toml +[tool.tryceratops] +exclude = ["samples"] +ignore = ["TRY002", "TRY200", "TRY300"] +experimental = true +``` +CLI flags always overwrite the config file. +## Pre-commit +If you wish to use pre-commit, add this: +```yaml + - repo: https://github.com/guilatrova/tryceratops + rev: v2.0.0 + hooks: + - id: tryceratops +``` +## Show your style +[](https://github.com/guilatrova/tryceratops) +Add this fancy badge to your project's `README.md`: +```md +[](https://github.com/guilatrova/tryceratops) +``` +## Extra Resources +If you want to read more about: +- [How to structure exceptions in Python 🐍 🏗️ 💣](https://blog.guilatrova.dev/how-to-structure-exception-in-python-like-a-pro/) +- [How to log in Python 🐍🌴](https://blog.guilatrova.dev/how-to-log-in-python-like-a-pro/) +- [Book: Effective Python](https://amzn.to/3bEVHpG) +## Contributing +Thank you for considering making Tryceratops better for everyone! +Refer to [Contributing docs](docs/CONTRIBUTING.md). +## Change log +See [CHANGELOG](CHANGELOG.md). +## License +MIT +## Credits +Thanks to God for the inspiration 🙌 ☁️ ☀️ +The [black](https://github.com/psf/black) project for insights. + +%package -n python3-tryceratops +Summary: Prevent Exception Handling AntiPatterns +Provides: python-tryceratops +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-tryceratops +## Installation and usage +### Installation +``` +pip install tryceratops +``` +OR +``` +poetry add -D tryceratops +``` +### Usage +``` +tryceratops [filename or dir...] +``` +You can enable experimental analyzers by running: +``` +tryceratops --experimental [filename or dir...] +``` +You can ignore specific violations by using: `--ignore TRYXXX` repeatedly: +``` +tryceratops --ignore TRY201 --ignore TRY202 [filename or dir...] +``` +You can exclude dirs by using: `--exclude dir/path` repeatedly: +``` +tryceratops --exclude tests --exclude .venv [filename or dir...] +``` +You can also autofix some violations: +``` +tryceratops --autofix [filename or dir...] +``` + +### [`flake8`](https://github.com/PyCQA/flake8) Plugin +🦖 Tryceratops is also a plugin for `flake8`, so you can: +``` +❯ flake8 --select TRY src/tests/samples/violations/call_raise_vanilla.py +src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY002 Create your own exception +src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY003 Avoid specifying long messages outside the exception class +src/tests/samples/violations/call_raise_vanilla.py:21:9: TRY201 Simply use 'raise' without specifying exception object again +``` +## Violations +All violations and its descriptions can be found in [docs](https://github.com/guilatrova/tryceratops/tree/main/docs/violations). +### Autofix support +So far, autofix only supports violations: [TRY200](docs/violations/TRY200.md), [TRY201](docs/violations/TRY201.md), and [TRY400](docs/violations/TRY400.md). +### Ignoring violations +If you want to ignore a violation in a specific file, you can either: +- Add a comment with `noqa` to the top of the file you want to ignore +- Add a comment with `noqa` to the line you want to ignore +- Add a comment with `noqa: CODE` to the line you want to ignore a specific violation +Example: +```py +def verbose_reraise_1(): + try: + a = 1 + except Exception as ex: + raise ex # noqa: TRY202 +``` +### Configuration +You can set up a `pyproject.toml` file to set rules. +This is useful to avoid reusing the same CLI flags over and over again and helps to define the structure of your project. +Example: +```toml +[tool.tryceratops] +exclude = ["samples"] +ignore = ["TRY002", "TRY200", "TRY300"] +experimental = true +``` +CLI flags always overwrite the config file. +## Pre-commit +If you wish to use pre-commit, add this: +```yaml + - repo: https://github.com/guilatrova/tryceratops + rev: v2.0.0 + hooks: + - id: tryceratops +``` +## Show your style +[](https://github.com/guilatrova/tryceratops) +Add this fancy badge to your project's `README.md`: +```md +[](https://github.com/guilatrova/tryceratops) +``` +## Extra Resources +If you want to read more about: +- [How to structure exceptions in Python 🐍 🏗️ 💣](https://blog.guilatrova.dev/how-to-structure-exception-in-python-like-a-pro/) +- [How to log in Python 🐍🌴](https://blog.guilatrova.dev/how-to-log-in-python-like-a-pro/) +- [Book: Effective Python](https://amzn.to/3bEVHpG) +## Contributing +Thank you for considering making Tryceratops better for everyone! +Refer to [Contributing docs](docs/CONTRIBUTING.md). +## Change log +See [CHANGELOG](CHANGELOG.md). +## License +MIT +## Credits +Thanks to God for the inspiration 🙌 ☁️ ☀️ +The [black](https://github.com/psf/black) project for insights. + +%package help +Summary: Development documents and examples for tryceratops +Provides: python3-tryceratops-doc +%description help +## Installation and usage +### Installation +``` +pip install tryceratops +``` +OR +``` +poetry add -D tryceratops +``` +### Usage +``` +tryceratops [filename or dir...] +``` +You can enable experimental analyzers by running: +``` +tryceratops --experimental [filename or dir...] +``` +You can ignore specific violations by using: `--ignore TRYXXX` repeatedly: +``` +tryceratops --ignore TRY201 --ignore TRY202 [filename or dir...] +``` +You can exclude dirs by using: `--exclude dir/path` repeatedly: +``` +tryceratops --exclude tests --exclude .venv [filename or dir...] +``` +You can also autofix some violations: +``` +tryceratops --autofix [filename or dir...] +``` + +### [`flake8`](https://github.com/PyCQA/flake8) Plugin +🦖 Tryceratops is also a plugin for `flake8`, so you can: +``` +❯ flake8 --select TRY src/tests/samples/violations/call_raise_vanilla.py +src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY002 Create your own exception +src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY003 Avoid specifying long messages outside the exception class +src/tests/samples/violations/call_raise_vanilla.py:21:9: TRY201 Simply use 'raise' without specifying exception object again +``` +## Violations +All violations and its descriptions can be found in [docs](https://github.com/guilatrova/tryceratops/tree/main/docs/violations). +### Autofix support +So far, autofix only supports violations: [TRY200](docs/violations/TRY200.md), [TRY201](docs/violations/TRY201.md), and [TRY400](docs/violations/TRY400.md). +### Ignoring violations +If you want to ignore a violation in a specific file, you can either: +- Add a comment with `noqa` to the top of the file you want to ignore +- Add a comment with `noqa` to the line you want to ignore +- Add a comment with `noqa: CODE` to the line you want to ignore a specific violation +Example: +```py +def verbose_reraise_1(): + try: + a = 1 + except Exception as ex: + raise ex # noqa: TRY202 +``` +### Configuration +You can set up a `pyproject.toml` file to set rules. +This is useful to avoid reusing the same CLI flags over and over again and helps to define the structure of your project. +Example: +```toml +[tool.tryceratops] +exclude = ["samples"] +ignore = ["TRY002", "TRY200", "TRY300"] +experimental = true +``` +CLI flags always overwrite the config file. +## Pre-commit +If you wish to use pre-commit, add this: +```yaml + - repo: https://github.com/guilatrova/tryceratops + rev: v2.0.0 + hooks: + - id: tryceratops +``` +## Show your style +[](https://github.com/guilatrova/tryceratops) +Add this fancy badge to your project's `README.md`: +```md +[](https://github.com/guilatrova/tryceratops) +``` +## Extra Resources +If you want to read more about: +- [How to structure exceptions in Python 🐍 🏗️ 💣](https://blog.guilatrova.dev/how-to-structure-exception-in-python-like-a-pro/) +- [How to log in Python 🐍🌴](https://blog.guilatrova.dev/how-to-log-in-python-like-a-pro/) +- [Book: Effective Python](https://amzn.to/3bEVHpG) +## Contributing +Thank you for considering making Tryceratops better for everyone! +Refer to [Contributing docs](docs/CONTRIBUTING.md). +## Change log +See [CHANGELOG](CHANGELOG.md). +## License +MIT +## Credits +Thanks to God for the inspiration 🙌 ☁️ ☀️ +The [black](https://github.com/psf/black) project for insights. + +%prep +%autosetup -n tryceratops-2.0.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-tryceratops -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 2.0.0-1 +- Package Spec generated |