Additional modifications to PR #681

This commit is contained in:
BJ Dierkes 2024-05-20 00:32:23 -04:00
parent 0866e525af
commit 70992b2f6d
17 changed files with 141 additions and 100 deletions

View File

@ -1,29 +0,0 @@
name: Upload Python Package
on:
release:
types: [published]
permissions:
id-token: write # trusted publishing
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

View File

@ -1,5 +1,43 @@
# ChangeLog
## 3.0.11 - DEVELOPMENT (will be released as stable/3.0.12)
Bugs:
- ?
Features:
- ?
Refactoring:
- `[dev]` Modernize Packaging (pyproject.toml, PDM)
- [Issue #680](https://github.com/datafolklabs/cement/issues/680)
- [PR #681](https://github.com/datafolklabs/cement/pull/681)
- `[dev]` Implement Ruff for Code Compliance
- [Issue #671](https://github.com/datafolklabs/cement/issues/671)
- [PR #681](https://github.com/datafolklabs/cement/pull/681)
- `[dev]` Remove Python 3.5, 3.6, 3.7 Docker Dev Targets
Misc:
- ?
Deprecations:
- ?
Special Recognitions:
Many thanks to `sigma67` for their contributions in modernizing the packaging system. Cement was started in 2009, and has some lingering technical debt that is now being addressed. Their contribution was a major help in moving off of setuptools and on to PDM and `pyproject.toml`, along with initial implementations of Ruff for a new generation of code compliance. I sincerely appreciate your help!
## 3.0.10 - Feb 28, 2024
Bugs:

View File

@ -4,7 +4,8 @@ ENV PS1="\[\e[0;33m\]|> cement <| \[\e[1;35m\]\W\[\e[0m\] \[\e[0m\]# "
WORKDIR /src
COPY . /src
ENV PDM_BUILD_SCM_VERSION=0.0.0.dev
RUN pip install . \
&& rm -rf /src
# RUN pip install . \
# && rm -rf /src
RUN pip install .
WORKDIR /
ENTRYPOINT ["/usr/local/bin/cement"]

View File

@ -2,7 +2,11 @@
dev:
docker-compose up -d
docker-compose exec cement pip install .
docker-compose exec cement pdm install
docker-compose exec cement-py38 pdm install
docker-compose exec cement-py39 pdm install
docker-compose exec cement-py310 pdm install
docker-compose exec cement-py311 pdm install
docker-compose exec cement /bin/bash
test: comply

View File

@ -1065,7 +1065,7 @@ class App(meta.MetaMixin):
"""
for res in self.hook.run('pre_render', self, data):
if not type(res) is dict:
if type(res) is not dict:
LOG.debug("pre_render hook did not return a dict().")
else:
data = res
@ -1090,7 +1090,7 @@ class App(meta.MetaMixin):
out_text = oh.render(data, **kw)
for res in self.hook.run('post_render', self, out_text):
if not type(res) is str:
if type(res) is not str:
LOG.debug('post_render hook did not return a str()')
else:
out_text = str(res)

View File

@ -476,7 +476,7 @@ class Prompt(MetaMixin):
if self._meta.case_insensitive is True:
lower_options = [x.lower()
for x in self._meta.options]
if not self.input.lower() in lower_options:
if self.input.lower() not in lower_options:
self.input = None
continue
else:

View File

@ -4,6 +4,32 @@ volumes:
mailpit-data:
services:
redis:
image: redis:latest
hostname: redis
memcached:
image: memcached:latest
hostname: memcached
mailpit:
image: axllent/mailpit
container_name: mailpit
restart: always
volumes:
- mailpit-data:/data
- ./docker/mailpit:/certificates
ports:
- 8025:8025
- 1025:1025
environment:
MP_MAX_MESSAGES: 5000
MP_DATA_FILE: /data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
MP_SMTP_TLS_CERT: /certificates/dev-cert.pem
MP_SMTP_TLS_KEY: /certificates/dev-key.pem
cement: &DEFAULTS
image: "cement:dev"
build:
@ -23,6 +49,10 @@ services:
MEMCACHED_HOST: memcached
SMTP_HOST: mailpit
SMTP_PORT: 1025
depends_on:
- redis
- memcached
- mailpit
cement-py38:
<<: *DEFAULTS
@ -51,29 +81,3 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.dev-py311
redis:
image: redis:latest
hostname: redis
memcached:
image: memcached:latest
hostname: memcached
mailpit:
image: axllent/mailpit
container_name: mailpit
restart: always
volumes:
- mailpit-data:/data
- ./docker/mailpit:/certificates
ports:
- 8025:8025
- 1025:1025
environment:
MP_MAX_MESSAGES: 5000
MP_DATA_FILE: /data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
MP_SMTP_TLS_CERT: /certificates/dev-cert.pem
MP_SMTP_TLS_KEY: /certificates/dev-key.pem

View File

@ -23,6 +23,6 @@ RUN pipx install pdm
ENV PATH="${PATH}:/root/.local/bin"
COPY . /src
COPY docker/vimrc /root/.vimrc
RUN pdm venv create
COPY docker/bashrc /root/.bashrc
RUN pdm install
CMD ["/bin/bash"]

View File

@ -23,6 +23,6 @@ RUN pipx install pdm
ENV PATH="${PATH}:/root/.local/bin"
COPY . /src
COPY docker/vimrc /root/.vimrc
RUN pdm venv create
COPY docker/bashrc /root/.bashrc
RUN pdm install
CMD ["/bin/bash"]

View File

@ -23,6 +23,6 @@ RUN pipx install pdm
ENV PATH="${PATH}:/root/.local/bin"
COPY . /src
COPY docker/vimrc /root/.vimrc
RUN pdm venv create
COPY docker/bashrc /root/.bashrc
RUN pdm install
CMD ["/bin/bash"]

View File

@ -23,6 +23,6 @@ RUN pipx install pdm
ENV PATH="${PATH}:/root/.local/bin"
COPY . /src
COPY docker/vimrc /root/.vimrc
RUN pdm venv create
COPY docker/bashrc /root/.bashrc
RUN pdm install
CMD ["/bin/bash"]

View File

@ -23,6 +23,6 @@ RUN pipx install pdm
ENV PATH="${PATH}:/root/.local/bin"
COPY . /src
COPY docker/vimrc /root/.vimrc
RUN pdm venv create
COPY docker/bashrc /root/.bashrc
RUN pdm install
CMD ["/bin/bash"]

View File

@ -23,6 +23,6 @@ RUN pipx install pdm
ENV PATH="${PATH}:/root/.local/bin"
COPY . /src
COPY docker/vimrc /root/.vimrc
RUN pdm venv create
COPY docker/bashrc /root/.bashrc
RUN pdm install
CMD ["/bin/bash"]

3
docker/bashrc Normal file
View File

@ -0,0 +1,3 @@
export PATH="${PATH}:/root/.local/bin"
alias cement='pdm run cement'

View File

@ -5,7 +5,7 @@
groups = ["default", "alarm", "argparse", "colorlog", "configparser", "daemon", "dev", "docs", "dummy", "generate", "jinja2", "json", "logging", "memcached", "mustache", "plugin", "print", "redis", "scrub", "smtp", "tabulate", "watchdog", "yaml"]
strategy = ["cross_platform", "inherit_metadata"]
lock_version = "4.4.1"
content_hash = "sha256:7ee1b527b606c4f99aa980b75b4591ee99f97bd57e78a773fcdb8c3b36f6fd93"
content_hash = "sha256:b3e19108389b63d5ab60634d76e82d6ef472cc06a5f8a81e98c57d30bf92c2b3"
[[package]]
name = "alabaster"
@ -451,6 +451,17 @@ files = [
{file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"},
]
[[package]]
name = "mock"
version = "5.1.0"
requires_python = ">=3.6"
summary = "Rolling backport of unittest.mock for all Pythons"
groups = ["dev"]
files = [
{file = "mock-5.1.0-py3-none-any.whl", hash = "sha256:18c694e5ae8a208cdb3d2c20a993ca1a7b0efa258c247a1e565150f477f83744"},
{file = "mock-5.1.0.tar.gz", hash = "sha256:5e96aad5ccda4718e0a229ed94b2024df75cc2d55575ba5762d31f5767b8767d"},
]
[[package]]
name = "mypy"
version = "1.9.0"

View File

@ -18,9 +18,6 @@ dynamic = ["version", "README"]
requires-python = ">=3.8"
dependencies = [
]
[project.optional-dependencies]
alarm = []
argparse = []
@ -44,6 +41,9 @@ tabulate = ["tabulate"]
watchdog = ["watchdog"]
yaml = ["pyYaml"]
[tool.pdm.scripts]
cement = {call = "cement.cli.main:main"}
[project.scripts]
cement = "cement.cli.main:main"
@ -94,10 +94,13 @@ dev = [
"coverage>=4.5.3",
"mypy>=1.9.0",
"ruff>=0.3.2",
"mock>=5.1.0",
]
[tool.ruff]
line-length = 100
target-version = "py38"
line-length = 99
indent-width = 4
exclude = [
".git",
"cement/cli/templates",
@ -105,25 +108,42 @@ exclude = [
]
[tool.ruff.lint]
extend-select = [
"F", # pyflakes
"E", "W", # pycodestyle
# "N", # pep8-naming - enable later, some variables are not lowercase
]
ignore = [
"E402",
"E713",
"E721",
"E714",
"F841",
"F507"
]
preview = true
extend-select = ["E", "F", "W"]
ignore = []
fixable = ["ALL"]
unfixable = []
# ignore = [
# "E402",
# "E713",
# "E721",
# "E714",
# "F841",
# "F507"
# ]
# TBD
# [tool.ruff.format]
# quote-style = "single"
# [[tool.mypy.overrides]]
# module = "cement.*"
# ignore_missing_imports = true
[tool.mypy]
python_version = "3.8"
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_any_unimported = false
disallow_incomplete_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
strict_optional = true
check_untyped_defs = true
warn_return_any = true
warn_unused_ignores = true
show_error_codes = true
files = [
"cement/",
# "tests/"
@ -134,14 +154,3 @@ exclude = """(?x)(
^.git/ |
^tests
)"""
# https://mypy.readthedocs.io/en/stable/config_file.html#untyped-definitions-and-calls
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
# https://mypy.readthedocs.io/en/stable/config_file.html#none-and-optional-handling
no_implicit_optional = true
strict_optional = true

View File

@ -15,7 +15,7 @@ def add(a, b):
def test_cmd():
out, err, ret = shell.cmd('echo KAPLA!')
out, err, ret = shell.cmd('echo KAPLA!') # noqa: F841
assert ret == 0
assert out == b'KAPLA!\n'
@ -24,13 +24,13 @@ def test_cmd():
def test_exec_cmd():
out, err, ret = shell.exec_cmd(['echo', 'KAPLA!'])
out, err, ret = shell.exec_cmd(['echo', 'KAPLA!']) # noqa: F841
assert ret == 0
assert out == b'KAPLA!\n'
def test_exec_cmd_shell_true():
out, err, ret = shell.exec_cmd(['echo KAPLA!'], shell=True)
out, err, ret = shell.exec_cmd(['echo KAPLA!'], shell=True) # noqa: F841
assert ret == 0
assert out == b'KAPLA!\n'
@ -46,7 +46,7 @@ def test_exec_cmd2_shell_true():
def test_exec_cmd_bad_command():
out, err, ret = shell.exec_cmd(['false'])
out, err, ret = shell.exec_cmd(['false']) # noqa: F841
assert ret == 1