From aaa277f61eacfc03430494aa878d75c80cc10b60 Mon Sep 17 00:00:00 2001 From: Marcel Wilson Date: Wed, 14 Feb 2024 15:21:53 -0600 Subject: [PATCH] rearrange pyproject for easier sync between packages --- .github/workflows/lint.yml | 2 +- Makefile | 33 ++++-- poetry.lock | 5 +- pyproject.toml | 211 ++++++++++++++++++------------------- 4 files changed, 130 insertions(+), 121 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9507910..a579204 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,7 +28,7 @@ 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_selenium diff --git a/Makefile b/Makefile index b47e564..5b6a012 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,17 @@ -# shortcuts +# 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 -trunk_screenpy: - poetry add screenpy git+ssh://git@github.com:ScreenPyHQ/screenpy.git#trunk - -local_screenpy: - pip uninstall screenpy - pip install -e ~/projects/screenpy - -.PHONY: sync update trunk_screenpy local_screenpy +.PHONY: sync update_lock_only update check black-check: black --check . @@ -42,3 +35,21 @@ 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 + +################################################################################ +# sub-package specific + +trunk_screenpy: + poetry add screenpy git+ssh://git@github.com:ScreenPyHQ/screenpy.git#trunk + +local_screenpy: + pip uninstall screenpy + pip install -e ~/projects/screenpy + +.PHONY: trunk_screenpy local_screenpy diff --git a/poetry.lock b/poetry.lock index 5313bf9..6512e1a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1529,11 +1529,10 @@ docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.link testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] [extras] -dev = ["pre-commit", "pytest", "tox"] -dev-all = ["black", "coverage", "mypy", "pre-commit", "pytest", "ruff", "sphinx", "tox"] +dev = ["black", "coverage", "mypy", "pre-commit", "pytest", "ruff", "sphinx", "tox"] test = ["coverage", "pytest"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "58d914781efe541f9a8b6411a11276d3bcc2817e464a000da361624ff28d5034" +content-hash = "11e295386bfc306fbbc02b2612fa571eaa6e30fdee1f2c5b6f403d34c3fb3b9e" diff --git a/pyproject.toml b/pyproject.toml index 16d87d2..759d4cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,24 @@ +# This pyproject.toml is setup so it can be used with or without poetry and also +# supports editable installs (PEP 660) without breaking IDE and linter inspection. + +# DEVELOPER INSTALL INSTRUCTIONS (assuming current directory is at the top of the project) : +# Poetry: +# poetry install --extras dev +# PIP: +# pip install -e .[dev] + +################################################################################ +# the following sections do not contain unique configurations to this package. +################################################################################ + + +[build-system] +requires = ["poetry-core>=1.2.0"] +build-backend = "poetry.core.masonry.api" + + [tool.black] target-version = ['py312'] - extend-exclude = ''' # A regex preceded with ^/ will apply only to files and directories # in the root of the project. @@ -15,107 +33,20 @@ extend-exclude = ''' ''' -# This pyproject.toml is setup so it can be used with or without poetry and also -# supports editable installs (PEP 660) without breaking IDE and linter inspection. - -# DEVELOPER INSTALL INSTRUCTIONS (assuming current directory is at the top of the project) : -# Poetry: -# poetry install --extras dev -# PIP: -# pip install -e .[dev] - -[tool.poetry] -name = "screenpy_selenium" -version = "4.0.4" -description = "ScreenPy extension to enable interacting with Selenium." -authors = ["Perry Goy "] -maintainers = ["Gabe Langton", "Marcel Wilson"] -license = "MIT" -repository = "https://github.com/ScreenPyHQ/screenpy_selenium" -documentation = "https://screenpy-selenium-docs.readthedocs.io" -readme = "README.md" -classifiers = [ - "Operating System :: OS Independent", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Topic :: Software Development :: Quality Assurance", - "Topic :: Software Development :: Testing", - "Topic :: Software Development :: Testing :: BDD", - "Natural Language :: English", - "License :: OSI Approved :: MIT License", -] - -# It's possible to add optional dependencies with the poetry CLI tool using: -# poetry add --optional some_dev_pkg -# This will set `optional = true` flag in [tool.poetry.dependencies], as seen below -# But then you need to remember to manually edit the [tool.poetry.extras] dev section -# and declare the package. This allows `pip install .[dev]` to work as expected -# Poetry users will need to use the `--extras dev` option rather than the `--with dev` -# so we dont have two different sets of package versions to update. - -[tool.poetry.dependencies] -python = "^3.8" -screenpy = ">=4.0.2" -screenpy_pyotp = ">=4.0.0" -selenium = ">=4.1.0" -importlib_metadata = {version = "*", python = "3.8.*"} - -# convenience packages for development of screenpy only -black = {version = "*", optional = true} -coverage = {version = "*", optional = true} -mypy = {version = "*", optional = true} -pre-commit = {version = "*", optional = true} -pytest = {version = "*", optional = true} -ruff = {version = ">=0.2.0", optional = true} -sphinx = {version = "*", optional = true} -tox = {version = "*", optional = true} - -[tool.poetry.extras] -dev = [ - "pre-commit", - "pytest", - "tox", -] -dev_all = [ - "black", - "coverage", - "mypy", - "pre-commit", - "pytest", - "ruff", - "sphinx", - "tox", -] -test = [ - "coverage", - "pytest", -] - -[build-system] -requires = ["poetry-core>=1.2.0"] -build-backend = "poetry.core.masonry.api" - [tool.ruff] target-version = "py38" # minimum supported version line-length = 88 # same as Black. - extend-exclude = [ - "screenpy_selenium/__init__.py", - "screenpy_selenium/__version__.py", + "__init__.py", + "__version__.py", "docs", ] [tool.ruff.lint] select = [ "A", # flake8-builtins - "ANN", # flake8-annotations # coming back to this one later to compare against mypy + "ANN", # flake8-annotations "ARG", # flake8-unused-arguments "B", # flake8-bugbear "BLE", # flake8-blind-except @@ -161,8 +92,7 @@ ignore = [ ] extend-safe-fixes = [ - "EM101", - "EM102", + "EM101", "EM102", "TCH001", "TCH002", "TCH003", "TCH004", "C419", "D200", "D205", "D415", @@ -171,6 +101,22 @@ extend-safe-fixes = [ "UP006", "UP007", ] +[tool.ruff.lint.flake8-pytest-style] +mark-parentheses = false + +[tool.ruff.lint.pycodestyle] +ignore-overlong-task-comments = true + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.flake8-type-checking] +strict = true + +[tool.ruff.lint.isort] +combine-as-imports = true +split-on-trailing-comma = false + [tool.ruff.lint.per-file-ignores] "tests/**" = [ "D", # we don't need public-API-polished docstrings in tests. @@ -178,23 +124,76 @@ extend-safe-fixes = [ "PLR", # likewise using specific numbers and strings in tests. ] -[tool.ruff.lint.isort] -combine-as-imports = true -split-on-trailing-comma = false -known-first-party = ["screenpy_selenium", "tests"] - -[tool.ruff.lint.flake8-pytest-style] -mark-parentheses = false +################################################################################ +# the following sections contain unique configurations to this package. +################################################################################ +[tool.poetry] +name = "screenpy_selenium" +version = "4.0.4" +description = "ScreenPy extension to enable interacting with Selenium." +authors = ["Perry Goy "] +maintainers = ["Gabe Langton", "Marcel Wilson"] +license = "MIT" +repository = "https://github.com/ScreenPyHQ/screenpy_selenium" +documentation = "https://screenpy-selenium-docs.readthedocs.io" +readme = "README.md" +classifiers = [ + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", + "Topic :: Software Development :: Testing :: BDD", + "Natural Language :: English", + "License :: OSI Approved :: MIT License", +] -[tool.ruff.lint.pycodestyle] -ignore-overlong-task-comments = true +# It's possible to add optional dependencies with the poetry CLI tool using: +# poetry add --optional some_dev_pkg +# This will set `optional = true` flag in [tool.poetry.dependencies], as seen below +# But then you need to remember to manually edit the [tool.poetry.extras] dev section +# and declare the package. This allows `pip install .[dev]` to work as expected +# Poetry users will need to use the `--extras dev` option rather than the `--with dev` +# so we dont have two different sets of package versions to update. +[tool.poetry.dependencies] +python = "^3.8" -[tool.ruff.lint.pydocstyle] -convention = "google" +screenpy = ">=4.0.2" +screenpy_pyotp = ">=4.0.0" +selenium = ">=4.1.0" +importlib_metadata = {version = "*", python = "3.8.*"} +# convenience packages for development +black = {version = "*", optional = true} +coverage = {version = "*", optional = true} +mypy = {version = "*", optional = true} +pre-commit = {version = "*", optional = true} +pytest = {version = "*", optional = true} +ruff = {version = ">=0.2.0", optional = true} +sphinx = {version = "*", optional = true} +tox = {version = "*", optional = true} -[tool.ruff.lint.flake8-type-checking] -strict = true +[tool.poetry.extras] +dev = [ + "black", + "coverage", + "mypy", + "pre-commit", + "pytest", + "ruff", + "sphinx", + "tox", +] +test = [ + "coverage", + "pytest", +]