Skip to content

Commit

Permalink
Ruff and project standardization (#11)
Browse files Browse the repository at this point in the history
* initial deps
* initial project sync (via cruft)
* ruff ANN
* updated test based on changes in ScreenPyHQ/screenpy#98
* ruff ARG
* ruff D
* ruff EM
* ruff FA
* ruff I
* ruff TCH
* ruff PGH
* ruff PIE
* ruff PT
* ruff RUF
* ruff SIM
* ruff UP
* black formatting
* fixing mypy namespace error
* adding copyright tests
* adding namespace test
* fixing name of mocked item since it's being patched at the class level.
  • Loading branch information
bandophahita authored Feb 26, 2024
1 parent fdfec47 commit 457e850
Show file tree
Hide file tree
Showing 25 changed files with 1,628 additions and 688 deletions.
26 changes: 12 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,30 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install -e .[dev-all]
pip install -e .[dev]
# - name: Run Cruft
# run: |
# cruft check
- name: Lint with black
run: |
black --check --diff screenpy_adapter_allure
- name: Lint with isort
black --check --diff .
- name: Lint with ruff
run: |
isort --check-only --diff screenpy_adapter_allure
- name: Lint with flake8
run: |
flake8 --exit-zero screenpy_adapter_allure
ruff check .
- name: Lint with mypy
run: |
mypy screenpy_adapter_allure
- name: Lint with pylint
run: |
pylint screenpy_adapter_allure
mypy .
10 changes: 5 additions & 5 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.12"]
os: [ubuntu-latest]
poetry-version: ["1.3.2"]
poetry-version: ["1.6.1"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -34,6 +34,6 @@ jobs:

- name: Check toml structure
run: poetry check

- name: Check lock file
run: poetry lock --check
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Poetry
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ jobs:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dev dependencies
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,6 @@ dmypy.json

# Pyre type checker
.pyre/

# ruff linter
.ruff_cache/
46 changes: 17 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
files: 'screenpy_adapter_allure/.*'
files: '(screenpy_adapter_allure|tests)/.*'
fail_fast: false
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
language_version: python3.11
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
language_version: python3.11
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
language_version: python3.11
additional_dependencies: ["allure-pytest>=2.9.0"]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint --max-line-length=88 --disable=bad-continuation --disable=no-self-use --disable=too-few-public-methods --disable=invalid-name --disable=wrong-import-order --disable=import-error --disable=super-init-not-called --disable=duplicate-code --disable=logging-format-interpolation --disable=logging-fstring-interpolation
language: system
types: [python]
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
language_version: python3.12
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.0
hooks:
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
language_version: python3.12
additional_dependencies: ["allure-pytest>=2.9.0"]
7 changes: 5 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ version: 2
build:
os: "ubuntu-20.04"
tools:
python: "3.11"
python: "3.12"

sphinx:
configuration: docs/conf.py

python:
install:
- requirements: docs/rtd-requirements.txt
- method: pip
path: .
extra_requirements:
- docs
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2023 Perry Goy
Copyright (c) 2022-2024 Perry Goy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# shortcuts to help manage flipping between branches with different dependencies
sync:
poetry install --extras dev --sync

update_lock_only:
poetry update --lock

update: update_lock_only
poetry install --extras dev

check:
poetry check

.PHONY: sync update_lock_only update check

black-check:
black --check .

black-fix:
black .

ruff-check:
ruff check .

ruff-fix:
ruff check . --fix --show-fixes

mypy:
mypy .

.PHONY: black-check black-fix ruff-check ruff-fix mypy

pre-check-in: black-check ruff-check mypy

pre-check-in-fix: black-fix ruff-fix mypy

.PHONY: pre-check-in pre-check-in-fix

# requires poetry-plugin-export
requirements:
poetry export --without-hashes --extras dev -f requirements.txt > requirements.txt

.PHONY: requirements
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
ScreenPy Adapter: Allure
========================

[![Build Status](../../actions/workflows/tests.yml/badge.svg)](../../actions/workflows/tests.yml)
[![Build Status](../../actions/workflows/lint.yml/badge.svg)](../../actions/workflows/lint.yml)

[![Supported Versions](https://img.shields.io/pypi/pyversions/screenpy_adapter_allure.svg)](https://pypi.org/project/screenpy_adapter_allure)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

```
TITLE CARD:
"ScreenPy Adapter: Allure"
Expand Down Expand Up @@ -53,7 +62,7 @@ or


Documentation
----------
-------------
Please check out the [Read The Docs documentation](https://screenpy-adapter-allure-docs.readthedocs.io/en/latest/) for the latest information about this module!

You can also read the [ScreenPy Docs](https://screenpy-docs.readthedocs.io/en/latest/) for more information about ScreenPy in general.
Expand All @@ -63,8 +72,13 @@ Contributing
------------
You want to contribute? Great! Here are the things you should do before submitting your PR:

1. Install [`pre-commit`](https://pre-commit.com/)
1. run `pre-commit install` once.
1. run `tox` to perform tests frequently.
1. Fork the repo and git clone your fork.
1. `dev` install the project package:
1. `pip install -e .[dev]`
1. Optional (poetry users):
1. `poetry install --extras dev`
1. Run `pre-commit install` once.
1. Run `tox` to perform tests frequently.
1. Create pull-request from your branch.

That's it! :)
14 changes: 13 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
[mypy]
show_error_codes = True
exclude = (?x)(
setup\.py
| docs/
)

[mypy-screenpy_adapter_allure.*]
disallow_untyped_defs = True

[mypy-tests.*]
disallow_untyped_defs = True
ignore_missing_imports = True

[mypy-allure.*]
ignore_missing_imports = True
[mypy-allure_commons.*]
ignore_missing_imports = True
[mypy-allure_pytest.*]
ignore_missing_imports = True
ignore_missing_imports = True
Loading

0 comments on commit 457e850

Please sign in to comment.