Skip to content

Commit

Permalink
Additional modifications to PR #681
Browse files Browse the repository at this point in the history
  • Loading branch information
derks committed May 20, 2024
1 parent 0866e52 commit 70992b2
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 100 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/pythonpublish.yml

This file was deleted.

38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cement/core/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ def render(self, data, template=None, out=sys.stdout, handler=None, **kw):
"""
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
Expand All @@ -1090,7 +1090,7 @@ def render(self, data, template=None, out=sys.stdout, handler=None, **kw):
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)
Expand Down
2 changes: 1 addition & 1 deletion cement/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def prompt(self):
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:
Expand Down
56 changes: 30 additions & 26 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -23,6 +49,10 @@ services:
MEMCACHED_HOST: memcached
SMTP_HOST: mailpit
SMTP_PORT: 1025
depends_on:
- redis
- memcached
- mailpit

cement-py38:
<<: *DEFAULTS
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev-py310
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev-py311
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev-py312
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev-py38
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev-py39
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 3 additions & 0 deletions docker/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

export PATH="${PATH}:/root/.local/bin"
alias cement='pdm run cement'
13 changes: 12 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 37 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ dynamic = ["version", "README"]

requires-python = ">=3.8"

dependencies = [
]

[project.optional-dependencies]
alarm = []
argparse = []
Expand All @@ -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"

Expand Down Expand Up @@ -94,36 +94,56 @@ 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",
"cement/cli/contrib"
]

[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/"
Expand All @@ -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
Loading

0 comments on commit 70992b2

Please sign in to comment.