Repository: thclark/rstcloth (language: python)

Issue:
make Sphinx dependency optional
Currently Sphinx dependency is not optional. I read the [current comment](https://github.com/thclark/rstcloth/blob/a3678e24a84af36c1a5b8267b0b76068e7f5f1d5/pyproject.toml#L33) the redirects to [this poetry issue](https://github.com/python-poetry/poetry/issues/3348), but now it is closed, and maybe the problem has been fixed. 

In any case I think that the current `sphinx = ">=2,<5"` dependency should 
* be moved under dev section 
* or at least be optional
* or at least updated to `sphinx = ">=2"` (is there any reason why the current 5 version is not ok?).

Currently this library cannot be used in a project with the currently latest Sphinx version (5.1.1)


Discussion / hints:
Hi @carlotardivo this is a bit confusing. Can you clarify please which of the following things you're trying to do:

1. install on a system where you DON'T want to install sphinx at the same time, and use rstcloth totally independently, or 
2. install on a system where you DO want sphinx at the same time, but want to use sphinx >=5?

If it's (1) can you make a use case for why you'd do that? I can see that you might want to just create `.rst` files for later rendering by a separate application (or use a rendering engine other than sphinx) but I think that'd be rare so I don't want to commit to supporting it unless I'm clear that there's a need for it (if there is a real need, I'm open to it, but need to check if we actually import sphinx anywhere to see how hard that is to achieve).

If it's (2) then it's simply a case of widening the sphinx version range to `sphinx = ">=2,<6" and adding sphinx 6 to the tox test matrix to make sure it works (to answer your question, I'm not aware of any reason it shouldn't work, but responsible management of a library demands that we actually test it before opening up the compatibility range.

Finally, can you clarify how moving it to the `dev` section would be useful? Is it just because that would be a workaround to the version range?

Hi @thclark, thanks for the response.

I'm currently on the situation (2). I have a project with the latest Sphinx version (>=5) installed, and for that reason in that environment I cannot install the RstCloth library. And yes, I was suggesting to move the sphinx dependency to the `dev` section just as a workaround to this (but I clearly was assuming that sphinx is actually a dev dependency).

 

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8801e94..5e0db29 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,33 +19,21 @@ jobs:
     if: "!contains(github.event.head_commit.message, 'skipci')"
     runs-on: ubuntu-latest
     steps:
-      - name: Checkout Repository
-        uses: actions/checkout@v2
+      - uses: actions/checkout@v3
         with:
-          # Set fetch-depth to 0 to fetch all tags (necessary for git-mkver to determine the correct semantic version).
+          # Set fetch-depth to 0 to fetch all tags (necessary for `git-mkver` to determine the correct semantic version).
           fetch-depth: 0
-
-      - name: Setup Python
-        uses: actions/setup-python@v2
-
-      - name: Install git-mkver
-        run: |
-          curl -L https://github.com/idc101/git-mkver/releases/download/v1.2.1/git-mkver-linux-amd64-1.2.1.tar.gz \
-          | tar xvz \
-          && sudo mv git-mkver /usr/local/bin
-
-      - name: Install semantic version checker
-        run: pip install git+https://github.com/octue/conventional-commits
-
-      - name: Check version
-        run: check-semantic-version pyproject.toml
+      - uses: octue/check-semantic-version@1.0.0.beta-9
+        with:
+          path: pyproject.toml
+          breaking_change_indicated_by: minor
 
   run-tests:
     if: "!contains(github.event.head_commit.message, 'skipci')"
     strategy:
       fail-fast: true
       matrix:
-        python: ["3.8", "3.9", "3.10"]
+        python: ["3.8", "3.9", "3.10", "3.11"]
         os: [ubuntu-latest] # [ubuntu-latest, windows-latest, macos-latest] for full coverage but this gets expensive quickly
     runs-on: ${{ matrix.os }}
 
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 17de0e4..f1b3df2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -31,19 +31,13 @@ repos:
         args: ["--line-length", "120"]
         language_version: python3
 
-  - repo: https://gitlab.com/pycqa/flake8
-    rev: 3.8.1
+  - repo: https://github.com/pycqa/flake8
+    rev: 6.0.0
     hooks:
       - id: flake8
         args: ["--config=setup.cfg"]
         language_version: python3
 
-  - repo: https://github.com/timothycrosley/isort
-    rev: 5.0.9
-    hooks:
-      - id: isort
-        require_serial: true
-
   - repo: https://github.com/windpioneers/pre-commit-hooks
     rev: 0.0.5
     hooks:
@@ -57,14 +51,13 @@ repos:
           #   my-branch-to-fix-issue-#6
           - "^([a-z][a-z0-9#]*)(-[a-z0-9#]+)*$"
 
-  # TODO Add prettier once all merging done
-  # - repo: https://github.com/pre-commit/mirrors-prettier
-  #   rev: "v2.2.1"
-  #   hooks:
-  #     - id: prettier
+  - repo: https://github.com/pre-commit/mirrors-prettier
+    rev: "v2.2.1"
+    hooks:
+      - id: prettier
 
-  - repo: https://github.com/octue/pre-commit-hooks
-    rev: 0.5.4
+  - repo: https://github.com/octue/conventional-commits
+    rev: 0.8.1
     hooks:
       - id: check-commit-message-is-conventional
         stages: [commit-msg]
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 462414f..09e40b4 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -12,9 +12,9 @@
 import os
 import re
 import sys
-
 import sphinx_rtd_theme
 
+
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
diff --git a/docs/source/index.rst b/docs/source/index.rst
index ee3c670..a280b22 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -70,4 +70,3 @@ Indices and tables
 * :ref:`genindex`
 * :ref:`modindex`
 * :ref:`search`
-
diff --git a/docs/source/installation.rst b/docs/source/installation.rst
index f3bea11..6f23396 100644
--- a/docs/source/installation.rst
+++ b/docs/source/installation.rst
@@ -14,4 +14,3 @@ Installation
 .. code-block:: python
 
    pip install rstcloth
-
diff --git a/pyproject.toml b/pyproject.toml
index be18b50..6b5ff57 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "rstcloth"
-version = "0.5.2"
+version = "0.5.3"
 description = "A simple Python API for generating RestructuredText."
 authors = ["Tom Clark"]
 license = "MIT"
@@ -26,8 +26,8 @@ packages = [{ include = "rstcloth" },]
 
 
 [tool.poetry.dependencies]
-python = ">=3.7,<3.11"
-sphinx = ">=2,<5"
+python = ">=3.7,<3.12"
+sphinx = ">=2,<6"
 Pygments = "^2.12.0"
 PyYAML = "^6.0"
 # These are here as extras to allow them to be installed as extras
diff --git a/rstcloth/__init__.py b/rstcloth/__init__.py
index 52262a1..1d8ea78 100644
--- a/rstcloth/__init__.py
+++ b/rstcloth/__init__.py
@@ -1,3 +1,4 @@
 from .rstcloth import RstCloth
 
-__all__ = ['RstCloth']
+
+__all__ = ["RstCloth"]
diff --git a/rstcloth/rstcloth.py b/rstcloth/rstcloth.py
index 60f7183..3a59e72 100644
--- a/rstcloth/rstcloth.py
+++ b/rstcloth/rstcloth.py
@@ -2,11 +2,11 @@
 import sys
 import textwrap
 import typing
-
 from tabulate import tabulate
 
 from rstcloth.utils import first_whitespace_position
 
+
 t_content = typing.Union[str, typing.List[str]]
 t_fields = typing.Iterable[typing.Tuple[str, str]]
 t_optional_2d_array = typing.Optional[typing.List[typing.List]]
diff --git a/tox.ini b/tox.ini
index 419e33a..4ec7841 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = {py38,py39,py310}-sphinx{2,3,4},docs
+envlist = {py38,py39,py310,py311}-sphinx{2,3,4,5},docs
 isolated_build = True
 
 [testenv]
@@ -13,6 +13,7 @@ deps =
     sphinx2: sphinx>=2,<3
     sphinx3: sphinx>=3,<4
     sphinx4: sphinx>=4,<5
+    sphinx5: sphinx>=5,<6
 
 [testenv:docs]
 whitelist_externals = rm
@@ -31,3 +32,4 @@ python =
     3.8: py38
     3.9: py39
     3.10: py310
+    3.11: py311


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 26dc265..77e11e0 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -5,16 +5,7 @@
 
 class TestUtils(unittest.TestCase):
     def test_first_whitespace_position(self):
-        matrix = (
-            ('spam ham', 4),
-            ('spam', 4),
-            ('', 0),
-            ('spam\tham', 4),
-            ('spam\nham', 4)
-        )
+        matrix = (("spam ham", 4), ("spam", 4), ("", 0), ("spam\tham", 4), ("spam\nham", 4))
         for string, position in matrix:
             with self.subTest(string=string, position=position):
-                self.assertEqual(
-                    first_whitespace_position(string),
-                    position
-                )
+                self.assertEqual(first_whitespace_position(string), position)