Skip to content

Commit

Permalink
Merge pull request #5 from bandophahita/ruff
Browse files Browse the repository at this point in the history
Ruff & project standardization
  • Loading branch information
bandophahita authored Feb 20, 2024
2 parents 02fadd1 + 499ef36 commit 796328a
Show file tree
Hide file tree
Showing 25 changed files with 961 additions and 879 deletions.
31 changes: 0 additions & 31 deletions .flake8

This file was deleted.

19 changes: 7 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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:
Expand All @@ -23,23 +23,18 @@ jobs:
uses: actions/setup-python@v4
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: Lint with black
run: |
black --check --diff screenpy_pyotp
- name: Lint with isort
black --check --diff .
- name: Lint with ruff
run: |
isort --check-only --diff screenpy_pyotp
- name: Lint with flake8
run: |
flake8 --exit-zero screenpy_pyotp
ruff check .
- name: Lint with mypy
run: |
mypy screenpy_pyotp
- name: Lint with pylint
run: |
pylint screenpy_pyotp
mypy .
6 changes: 3 additions & 3 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ 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
Expand All @@ -34,6 +34,6 @@ jobs:

- name: Check toml structure
run: poetry check

- name: Check lock file
run: poetry lock --check
25 changes: 13 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ 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
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
- name: Test with tox
run: tox
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/
6 changes: 0 additions & 6 deletions .isort.cfg

This file was deleted.

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_pyotp/.*'
files: '(screenpy_pyotp|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: ["pyotp>=2.3.0"]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
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: ["pyotp>=2.3.0"]
15 changes: 0 additions & 15 deletions .pylintrc

This file was deleted.

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
46 changes: 42 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
# shortcuts to help manage flipping between branches with different dependencies
sync:
poetry install --extras dev_all --sync
poetry install --extras dev --sync

update_lock_only:
poetry update --lock

update: update_lock_only
poetry install --extras dev_all
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 --with dev -f requirements.txt > requirements.txt
poetry export --without-hashes --extras dev -f requirements.txt > requirements.txt

.PHONY: requirements

################################################################################
# sub-package specific

trunk_screenpy:
poetry add screenpy git+ssh://[email protected]:ScreenPyHQ/screenpy.git#trunk

local_screenpy:
pip uninstall screenpy
pip install -e ~/projects/screenpy

.PHONY: sync update_lock_only update check requirements
.PHONY: trunk_screenpy local_screenpy
62 changes: 30 additions & 32 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,70 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

#
import os
import sys

sys.path.insert(0, os.path.abspath("./ext"))
sys.path.insert(0, os.path.abspath("../"))

from screenpy_pyotp.__version__ import __version__ # noqa: need the path first
from screenpy_pyotp.__version__ import __author__, __copyright__, __version__

autodoc_mock_imports = ["pyotp", "screenpy"]


# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'ScreenPy PyOTP'
copyright = '2022-2023, Perry Goy'
author = 'Perry Goy'

# The full version, including alpha/beta/rc tags
project = "ScreenPy PyOTP"
copyright = __copyright__
author = __author__
release = __version__


# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.intersphinx",
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.intersphinx",
"sphinx_rtd_theme",
"autodoc_skip_protocols",
]

intersphinx_mapping = {
"screenpy": ("https://screenpy-docs.readthedocs.io/en/latest/", None),
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Other HTML settings





# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = []

autodoc_member_order = "bysource"
add_module_names = False


# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"screenpy": ("https://screenpy-docs.readthedocs.io/en/latest/", None),
}
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
show_error_codes = True
exclude = (?x)(
setup\.py
; | tests/
| docs/
)

[mypy-screenpy_pyotp.*]
disallow_untyped_defs = True

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

0 comments on commit 796328a

Please sign in to comment.