From a547517ed5eab09801cb61f875f6340550aa13bd Mon Sep 17 00:00:00 2001 From: Marcel Wilson Date: Wed, 14 Feb 2024 15:23:54 -0600 Subject: [PATCH] rearrange pyproject for easier sync between packages --- .github/workflows/lint.yml | 2 +- Makefile | 35 +++--- poetry.lock | 5 +- pyproject.toml | 217 ++++++++++++++++++------------------- 4 files changed, 132 insertions(+), 127 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c47e78c..30cd062 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,7 +27,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 . diff --git a/Makefile b/Makefile index a53da43..65f0b57 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,17 @@ # 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 - -requirements: - poetry export --without-hashes --with dev -f requirements.txt > requirements.txt - -.PHONY: sync update trunk_screenpy local_screenpy, requirements +.PHONY: sync update_lock_only update check black-check: black --check . @@ -46,3 +36,22 @@ 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 6fe60c7..7522551 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1310,11 +1310,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", "pytest-mock", "tox"] -dev-all = ["black", "coverage", "mypy", "pre-commit", "pytest", "pytest-mock", "ruff", "sphinx", "tox"] +dev = ["black", "coverage", "mypy", "pre-commit", "pytest", "pytest-mock", "ruff", "sphinx", "tox"] test = ["coverage", "pytest", "pytest-mock"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "afaa3e2ae940354d63538b73fb4d262b088738f0308dda87ff286b0d46ee9ad6" +content-hash = "5e95891fd6fd63ac520f2f591ae2757c5071418a8eb895f7a69664a68e192500" diff --git a/pyproject.toml b/pyproject.toml index 5604fc5..82c2df7 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,111 +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_requests" -version = "4.0.3" -description = "ScreenPy extension to enable interacting with Requests." -authors = ["Perry Goy "] -maintainers = ["Marcel Wilson"] -license = "MIT" -repository = "https://github.com/ScreenPyHQ/screenpy_requests" -documentation = "https://screenpy-requests-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" -requests = ">=2.26.0" -types-requests = ">=2.26.0" - - -# convenience packages for development of screenpy_requests only -black = {version = "*", optional = true} -coverage = {version = "*", optional = true} -mypy = {version = "*", optional = true} -pre-commit = {version = "*", optional = true} -pytest = {version = "*", optional = true} -pytest-mock = {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", - "pytest-mock", - "tox", -] -dev_all = [ - "black", - "coverage", - "mypy", - "pre-commit", - "pytest", - "pytest-mock", - "ruff", - "sphinx", - "tox", -] -test = [ - "coverage", - "pytest", - "pytest-mock", -] - -[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_requests/__init__.py", - "screenpy_requests/__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 @@ -165,8 +92,7 @@ ignore = [ ] extend-safe-fixes = [ - "EM101", - "EM102", + "EM101", "EM102", "TCH001", "TCH002", "TCH003", "TCH004", "C419", "D200", "D205", "D415", @@ -175,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. @@ -183,22 +125,77 @@ extend-safe-fixes = [ ] -[tool.ruff.lint.isort] -combine-as-imports = true -split-on-trailing-comma = false -known-first-party = ["screenpy_requests", "tests"] - +################################################################################ +# the following sections contain unique configurations to this package. +################################################################################ -[tool.ruff.lint.flake8-pytest-style] -mark-parentheses = false +[tool.poetry] +name = "screenpy_requests" +version = "4.0.3" +description = "ScreenPy extension to enable interacting with Requests." +authors = ["Perry Goy "] +maintainers = ["Marcel Wilson"] +license = "MIT" +repository = "https://github.com/ScreenPyHQ/screenpy_requests" +documentation = "https://screenpy-requests-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.ruff.lint.pycodestyle] -ignore-overlong-task-comments = true +[tool.poetry.dependencies] +python = "^3.8" +screenpy = ">=4.0.2" +requests = ">=2.26.0" +types-requests = ">=2.26.0" -[tool.ruff.lint.pydocstyle] -convention = "google" +# 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} +pytest-mock = {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", + "pytest-mock", + "ruff", + "sphinx", + "tox", +] +test = [ + "coverage", + "pytest", + "pytest-mock", +]