Skip to content

Commit

Permalink
Merge pull request #672 from robtaylor/python-3.12
Browse files Browse the repository at this point in the history
Enable python =>3.9 <=3.12, and fix so checks work on OSX
  • Loading branch information
jacebrowning authored Oct 7, 2024
2 parents 7865edf + 7fe35ee commit 73032f7
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 163 deletions.
5 changes: 3 additions & 2 deletions .pylint.ini
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ disable=
logging-fstring-interpolation,
unnecessary-dunder-call,
deprecated-module,
deprecated-argument,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -418,5 +419,5 @@ known-third-party=enchant
[EXCEPTIONS]

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
# "builtin.Exception"
overgeneral-exceptions=builtin.Exception
6 changes: 3 additions & 3 deletions .verchew.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ version = GNU Make

[Python]

cli = python
cli = python3
version = 3.9 || 3.10 || 3.11 || 3.12

[Poetry]

cli = poetry
version = 1.7
version = 1.7 || 1.8

[Graphviz]

cli = dot
cli_version_arg = -V
version = 9 || 10
version = 9 || 10 || 11 || 12
optional = true
message = This is only needed to generate UML diagrams for documentation.
2 changes: 1 addition & 1 deletion bin/checksum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import hashlib
Expand Down
2 changes: 1 addition & 1 deletion bin/verchew
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# The MIT License (MIT)
Expand Down
9 changes: 5 additions & 4 deletions doorstop/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ def run_export(args, cwd, error, catch=True, auto=False, _tree=None):
ext = utilities.get_ext(args, error, ".yml", ".csv", whole_tree=whole_tree)

# Get the tree or document
document = None

with utilities.capture(catch=catch) as success:
exporter.check(ext)
tree = _tree or _get_tree(args, cwd, load=whole_tree)
Expand Down Expand Up @@ -547,6 +549,7 @@ def run_publish(args, cwd, error, catch=True):
ext = utilities.get_ext(args, error, ".txt", ".html", whole_tree)

# Get the tree or document
document = None
with utilities.capture(catch=catch) as success:
publisher.check(ext)
tree = _get_tree(args, cwd, load=whole_tree)
Expand Down Expand Up @@ -665,12 +668,10 @@ def _iter_items(args, tree, error):
if item:
yield item
elif document:
for item in document:
yield item
yield from document
else:
for document in tree:
for item in document:
yield item
yield from document


def _export_import(args, cwd, error, document, ext):
Expand Down
6 changes: 3 additions & 3 deletions doorstop/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ def main(args=None): # pylint: disable=R0915
log.error(exc)
success = False
except KeyboardInterrupt:
log.debug("command cancelled")
log.debug(f"command cancelled: {args}")
success = False
if success:
log.debug("command succeeded")
log.debug("command succeeded: {args}")
else:
log.debug("command failed")
log.debug(f"command failed: {args}")
sys.exit(1)


Expand Down
3 changes: 1 addition & 2 deletions doorstop/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ def read_lines(path, encoding="utf-8"):
"""
log.trace("reading lines from '{}'...".format(path)) # type: ignore
with open(path, "r", encoding=encoding) as stream:
for line in stream:
yield line
yield from stream


def read_text(path):
Expand Down
4 changes: 4 additions & 0 deletions doorstop/core/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def launch(path, tool=None):
args = ["start", path]
elif os.name == "posix":
args = ["xdg-open", path]
else:
raise DoorstopError(
"unknown operating system, unable to determine launch command"
)

# Launch the editor
try:
Expand Down
10 changes: 10 additions & 0 deletions doorstop/core/tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,16 @@ def test_launch_os_posix(self, mock_call):
self.assertRaises(DoorstopError, doorstop.core.editor.launch, "")
mock_call.assert_called_once_with(["xdg-open", ""])

@patch("doorstop.core.editor.os.name", "unknown")
@patch("doorstop.core.editor.sys.platform", "unknown")
@patch("doorstop.core.editor.shutil.which")
@patch("doorstop.core.editor._call")
def test_launch_os_unknown(self, mock_call, mock_which):
mock_call.side_effect = FileNotFoundError
mock_which.return_value = "unknown"
self.assertRaises(DoorstopError, doorstop.core.editor.launch, "")
mock_call.assert_not_called()

def test_link(self):
"""Verify links can be added to an item."""
self.item.link("abc")
Expand Down
171 changes: 27 additions & 144 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ classifiers = [

[tool.poetry.dependencies]

python = "^3.9"
python = "<3.13,>=3.9"

pyyaml = "^6.0"
markdown = "^3.3.3"
Expand All @@ -54,6 +54,7 @@ python-markdown-math = "~0.6"
plantuml-markdown = "^3.4.2"
six = "*" # fixes https://github.com/dougn/python-plantuml/issues/11
openpyxl = ">=3.1.2"
verchew = "^3.4.2"

[tool.poetry.dev-dependencies]

Expand All @@ -62,9 +63,9 @@ black = "^24.3"
isort = "^5.12"

# Linters
mypy = "^1.1.1"
mypy = ">=1.1.1"
pydocstyle = "*"
pylint = "~2.15"
pylint = "~3.2.0"
types-markdown = "*"
types-pyyaml = "*"
types-requests = "*"
Expand Down Expand Up @@ -106,6 +107,12 @@ quiet = true

profile = "black"

[tool.pytest.ini_options]
# log_cli = true
# log_cli_level = "WARNING"
log_file = "pytest.log"
log_file_level = "DEBUG"

[build-system]

requires = ["poetry-core"]
Expand Down

0 comments on commit 73032f7

Please sign in to comment.