Skip to content

Commit

Permalink
Project standardization (#128)
Browse files Browse the repository at this point in the history
* rearrange pyproject for easier sync between packages
* linter fixes after updating isort split-on-trailing-comma
* sync mypy.ini
* sync lint.yaml
* sync .precommit
* sync .gitignore
* sync __version__.py
* avoiding ScreenPyHQ/screenpy_selenium#36
* adding copyright year test
* sync conf.py
* setting up docs installation via pyproject.toml
* centering ascii art
* adjusting boilerplate pyproject.toml based on feedback
* slightly more tidy boilerplate.
* fixing underlines for Either
* adding test for license copyright year
  • Loading branch information
bandophahita authored Feb 16, 2024
1 parent 1c8a8b2 commit 59dc96f
Show file tree
Hide file tree
Showing 15 changed files with 400 additions and 477 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ jobs:
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
black --check --diff tests
- name: Lint with mypy
run: |
mypy screenpy
mypy tests
black --check --diff .
- name: Lint with ruff
run: |
ruff check .
- name: Lint with mypy
run: |
mypy .
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/
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
files: '(screenpy|tests)/.*'
fail_fast: false
repos:
- 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
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: ["PyHamcrest", "pytest"]
- 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
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: ["PyHamcrest", "pytest"]

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
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
# 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

requirements:
poetry export --without-hashes --with dev -f requirements.txt > requirements.txt

.PHONY: sync update_lock_only update check requirements
.PHONY: sync update_lock_only update check

black-check:
black --check .

black:
black-fix:
black .

ruff:
ruff-check:
ruff check .

ruff-fix:
Expand All @@ -31,12 +28,16 @@ ruff-fix:
mypy:
mypy .

lint: ruff mypy

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

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

pre-check-in-fix: black ruff-fix 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
2 changes: 1 addition & 1 deletion docs/api/actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Silently


Either
-----
------

**Aliases**: ``Attempt``,
``AttemptTo``,
Expand Down
157 changes: 11 additions & 146 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

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

Expand All @@ -18,31 +15,23 @@
sys.path.insert(0, os.path.abspath("./ext"))
sys.path.insert(0, os.path.abspath("../"))

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

autodoc_mock_imports = ["hamcrest", "pydantic"]


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

project = "ScreenPy"
copyright = __copyright__
author = __author__

# The short X.Y version
version = ""
# The full version, including alpha/beta/rc tags
release = __version__


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

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# 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.autodoc",
"sphinx.ext.autosectionlabel",
Expand All @@ -52,152 +41,28 @@
"autodoc_skip_protocols",
]

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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"

rst_prolog = """"""

# The master toctree document.
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"

# 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 = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#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 = "sphinx_rtd_theme"
html_static_path = []

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# 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"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}

# Other HTML settings
autodoc_member_order = "bysource"
add_module_names = False


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "ScreenPydoc"


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "ScreenPy.tex", "ScreenPy Documentation", "Perry Goy", "manual"),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "screenpy", "ScreenPy Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"ScreenPy",
"ScreenPy Documentation",
author,
"ScreenPy",
"A solid, SOLID base for automated testing using Screenplay Pattern in Python.",
"Automated Testing",
),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ["search.html"]


# -- Extension configuration -------------------------------------------------

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

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
}


# -- Options for Autodoc Pydantic extension ----------------------------------

# Don't show the JSON schema for BaseSettings extensions
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ the normal logging will take place::


Using Either
===========
============

Sometimes you may need to use a try/except control flow in your test,
for one reason or another.
Expand Down
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
show_error_codes = True
exclude = (?x)(
setup\.py
; | tests/
| docs/
)

Expand All @@ -12,5 +11,3 @@ disallow_untyped_defs = True
[mypy-tests.*]
disallow_untyped_defs = True
ignore_missing_imports = True


Loading

0 comments on commit 59dc96f

Please sign in to comment.