diff --git a/lectern/contrib/define.py b/lectern/contrib/define.py index 534e9d0..5c1e44f 100644 --- a/lectern/contrib/define.py +++ b/lectern/contrib/define.py @@ -1,6 +1,5 @@ """Plugin that adds a directive for rendering a fragment and storing the output.""" - __all__ = [ "DefineDirective", ] diff --git a/lectern/contrib/messaging.py b/lectern/contrib/messaging.py index 97e9b92..d3347c0 100644 --- a/lectern/contrib/messaging.py +++ b/lectern/contrib/messaging.py @@ -1,6 +1,5 @@ """Plugin for handling markdown coming from messaging apps.""" - __all__ = [ "MessagingOptions", "messaging", diff --git a/lectern/contrib/plugin.py b/lectern/contrib/plugin.py index c81cb13..dea7b8d 100644 --- a/lectern/contrib/plugin.py +++ b/lectern/contrib/plugin.py @@ -1,6 +1,5 @@ """Plugin that adds a directive for running plugin code in a document.""" - __all__ = [ "PluginDirective", ] diff --git a/lectern/contrib/relative_location.py b/lectern/contrib/relative_location.py index cbda97c..b102fba 100644 --- a/lectern/contrib/relative_location.py +++ b/lectern/contrib/relative_location.py @@ -1,6 +1,5 @@ """Plugin that handles relative resource locations.""" - __all__ = [ "RelativeNamespacedResourceLoader", ] diff --git a/lectern/contrib/require.py b/lectern/contrib/require.py index 3ab40d9..bff86b6 100644 --- a/lectern/contrib/require.py +++ b/lectern/contrib/require.py @@ -1,6 +1,5 @@ """Plugin that adds a directive for requiring plugins dynamically.""" - __all__ = [ "RequireDirective", ] diff --git a/lectern/contrib/script.py b/lectern/contrib/script.py index fd38d1e..c95003a 100644 --- a/lectern/contrib/script.py +++ b/lectern/contrib/script.py @@ -1,6 +1,5 @@ """Plugin that adds a directive for interpreting lectern text templates.""" - __all__ = [ "ScriptDirective", ] diff --git a/lectern/contrib/yaml_to_json.py b/lectern/contrib/yaml_to_json.py index ad4573b..aa22dbb 100644 --- a/lectern/contrib/yaml_to_json.py +++ b/lectern/contrib/yaml_to_json.py @@ -1,6 +1,5 @@ """Plugin that handles yaml fragments for json files.""" - __all__ = [ "handle_yaml", ] diff --git a/lectern/directive.py b/lectern/directive.py index 1bb8238..83d4012 100644 --- a/lectern/directive.py +++ b/lectern/directive.py @@ -24,8 +24,7 @@ class Directive(Protocol): """Protocol for detecting directives.""" - def __call__(self, fragment: Fragment, assets: ResourcePack, data: DataPack, /): - ... + def __call__(self, fragment: Fragment, assets: ResourcePack, data: DataPack, /): ... class DirectiveRegistry(Container[str, Directive]): diff --git a/lectern/document.py b/lectern/document.py index 0ff4529..ec699f8 100644 --- a/lectern/document.py +++ b/lectern/document.py @@ -146,12 +146,10 @@ def get_markdown( self, emit_external_files: Literal[True], prefix: str = "", - ) -> Tuple[str, Dict[str, File[Any, Any]]]: - ... + ) -> Tuple[str, Dict[str, File[Any, Any]]]: ... @overload - def get_markdown(self, emit_external_files: Literal[False] = False) -> str: - ... + def get_markdown(self, emit_external_files: Literal[False] = False) -> str: ... def get_markdown( self, diff --git a/lectern/extract.py b/lectern/extract.py index 18435ec..934bc15 100644 --- a/lectern/extract.py +++ b/lectern/extract.py @@ -586,9 +586,11 @@ def parse_inline( or ( (directory := RELATIVE_PATH_REGEX.match(code.content)) and ( - directive := "@resource_pack" - if directory[0] == "assets" - else "@data_pack" + directive := ( + "@resource_pack" + if directory[0] == "assets" + else "@data_pack" + ) ) and regex.match(f"{directive} {code.content}") ) diff --git a/lectern/fragment.py b/lectern/fragment.py index b5671aa..ed6d17b 100644 --- a/lectern/fragment.py +++ b/lectern/fragment.py @@ -68,16 +68,13 @@ def with_link( return replace(self, url=url, path=path) @overload - def expect(self) -> None: - ... + def expect(self) -> None: ... @overload - def expect(self, name1: str, /) -> str: - ... + def expect(self, name1: str, /) -> str: ... @overload - def expect(self, name1: str, name2: str, /, *names: str) -> Sequence[str]: - ... + def expect(self, name1: str, name2: str, /, *names: str) -> Sequence[str]: ... def expect(self, *names: str): """Check directive arguments.""" @@ -94,12 +91,10 @@ def expect(self, *names: str): return self.arguments @overload - def as_file(self) -> BinaryFile: - ... + def as_file(self) -> BinaryFile: ... @overload - def as_file(self, file_type: Type[FileType]) -> FileType: - ... + def as_file(self, file_type: Type[FileType]) -> FileType: ... def as_file(self, file_type: Type[File[Any, Any]] = BinaryFile) -> File[Any, Any]: """Retrieve the content of the fragment as a file.""" diff --git a/lectern/prefetch.py b/lectern/prefetch.py index 6fcda58..89046ac 100644 --- a/lectern/prefetch.py +++ b/lectern/prefetch.py @@ -66,15 +66,17 @@ def prefetch_urls( ) -> str: """Replace remote urls in the input by data urls or links to local files.""" return "".join( - self.rewrite_fragment( - text, - fragment.url, - fragment, - external_files, - external_prefix, + ( + self.rewrite_fragment( + text, + fragment.url, + fragment, + external_files, + external_prefix, + ) + if fragment and fragment.url + else text ) - if fragment and fragment.url - else text for text, fragment in self.extractor.split(source, directives) ) diff --git a/poetry.lock b/poetry.lock index d4c2a04..2080949 100644 --- a/poetry.lock +++ b/poetry.lock @@ -41,30 +41,34 @@ image = ["Pillow"] [[package]] name = "black" -version = "23.11.0" +version = "24.3.0" description = "The uncompromising code formatter." category = "dev" optional = false python-versions = ">=3.8" files = [ - {file = "black-23.11.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dbea0bb8575c6b6303cc65017b46351dc5953eea5c0a59d7b7e3a2d2f433a911"}, - {file = "black-23.11.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:412f56bab20ac85927f3a959230331de5614aecda1ede14b373083f62ec24e6f"}, - {file = "black-23.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d136ef5b418c81660ad847efe0e55c58c8208b77a57a28a503a5f345ccf01394"}, - {file = "black-23.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:6c1cac07e64433f646a9a838cdc00c9768b3c362805afc3fce341af0e6a9ae9f"}, - {file = "black-23.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cf57719e581cfd48c4efe28543fea3d139c6b6f1238b3f0102a9c73992cbb479"}, - {file = "black-23.11.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:698c1e0d5c43354ec5d6f4d914d0d553a9ada56c85415700b81dc90125aac244"}, - {file = "black-23.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:760415ccc20f9e8747084169110ef75d545f3b0932ee21368f63ac0fee86b221"}, - {file = "black-23.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:58e5f4d08a205b11800332920e285bd25e1a75c54953e05502052738fe16b3b5"}, - {file = "black-23.11.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:45aa1d4675964946e53ab81aeec7a37613c1cb71647b5394779e6efb79d6d187"}, - {file = "black-23.11.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4c44b7211a3a0570cc097e81135faa5f261264f4dfaa22bd5ee2875a4e773bd6"}, - {file = "black-23.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2a9acad1451632021ee0d146c8765782a0c3846e0e0ea46659d7c4f89d9b212b"}, - {file = "black-23.11.0-cp38-cp38-win_amd64.whl", hash = "sha256:fc7f6a44d52747e65a02558e1d807c82df1d66ffa80a601862040a43ec2e3142"}, - {file = "black-23.11.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7f622b6822f02bfaf2a5cd31fdb7cd86fcf33dab6ced5185c35f5db98260b055"}, - {file = "black-23.11.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:250d7e60f323fcfc8ea6c800d5eba12f7967400eb6c2d21ae85ad31c204fb1f4"}, - {file = "black-23.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5133f5507007ba08d8b7b263c7aa0f931af5ba88a29beacc4b2dc23fcefe9c06"}, - {file = "black-23.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:421f3e44aa67138ab1b9bfbc22ee3780b22fa5b291e4db8ab7eee95200726b07"}, - {file = "black-23.11.0-py3-none-any.whl", hash = "sha256:54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e"}, - {file = "black-23.11.0.tar.gz", hash = "sha256:4c68855825ff432d197229846f971bc4d6666ce90492e5b02013bcaca4d9ab05"}, + {file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"}, + {file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"}, + {file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"}, + {file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"}, + {file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"}, + {file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"}, + {file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"}, + {file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"}, + {file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"}, + {file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"}, + {file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"}, + {file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"}, + {file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"}, + {file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"}, + {file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"}, + {file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"}, + {file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"}, + {file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"}, + {file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"}, + {file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"}, + {file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"}, + {file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"}, ] [package.dependencies] @@ -78,7 +82,7 @@ typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] +d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] @@ -495,21 +499,18 @@ files = [ [[package]] name = "isort" -version = "5.12.0" +version = "5.13.2" description = "A Python utility / library to sort Python imports." category = "dev" optional = false python-versions = ">=3.8.0" files = [ - {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, - {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, + {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, + {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, ] [package.extras] -colors = ["colorama (>=0.4.3)"] -pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] -plugins = ["setuptools"] -requirements-deprecated-finder = ["pip-api", "pipreqs"] +colors = ["colorama (>=0.4.6)"] [[package]] name = "jaraco-classes" @@ -852,14 +853,14 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-co [[package]] name = "pluggy" -version = "1.3.0" +version = "1.4.0" description = "plugin and hook calling mechanisms for python" category = "dev" optional = false python-versions = ">=3.8" files = [ - {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, - {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, + {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, + {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, ] [package.extras] @@ -1033,14 +1034,14 @@ plugins = ["importlib-metadata"] [[package]] name = "pytest" -version = "7.4.3" +version = "8.1.1" description = "pytest: simple powerful testing with Python" category = "dev" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-7.4.3-py3-none-any.whl", hash = "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac"}, - {file = "pytest-7.4.3.tar.gz", hash = "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5"}, + {file = "pytest-8.1.1-py3-none-any.whl", hash = "sha256:2a8386cfc11fa9d2c50ee7b2a57e7d898ef90470a7a34c4b949ff59662bb78b7"}, + {file = "pytest-8.1.1.tar.gz", hash = "sha256:ac978141a75948948817d360297b7aae0fcb9d6ff6bc9ec6d514b85d5a65c044"}, ] [package.dependencies] @@ -1048,26 +1049,26 @@ colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<2.0" -tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} +pluggy = ">=1.4,<2.0" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-insta" -version = "0.2.0" +version = "0.3.0" description = "A practical snapshot testing plugin for pytest" category = "dev" optional = false -python-versions = ">=3.8,<4.0" +python-versions = ">=3.10,<4.0" files = [ - {file = "pytest_insta-0.2.0-py3-none-any.whl", hash = "sha256:e8d8a19f44917fa70102b132ddd4d6afcebe2a31987422dc79458ff849fe1a9e"}, - {file = "pytest_insta-0.2.0.tar.gz", hash = "sha256:c4e549f3c5aea8acf1ae6da12cffaaf4e4b3b03d9059c5115deab59f37b23867"}, + {file = "pytest_insta-0.3.0-py3-none-any.whl", hash = "sha256:93a105e3850f2887b120a581923b10bb313d722e00d369377a1d91aa535df704"}, + {file = "pytest_insta-0.3.0.tar.gz", hash = "sha256:9e6e1c70a021f68ccc4643360b2c2f8326cf3befba85f942c1da17b9caf713f7"}, ] [package.dependencies] -pytest = ">=7.2.0,<8.0.0" +pytest = ">=7.2.0,<9.0.0" wrapt = ">=1.14.1,<2.0.0" [[package]] @@ -1536,4 +1537,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "4280621b17ed8848910f636bb3e8a64aa4fcadd2d09c551fe08ef873f06570fe" +content-hash = "5ba1e4cf563fee33e9e7c50e8350e0247a673602db2853799ea62de6f222d018" diff --git a/pyproject.toml b/pyproject.toml index de8cf2a..7af100b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,11 +30,11 @@ markdown-it-py = "^3.0.0" click = "^8.1.7" [tool.poetry.group.dev.dependencies] -black = "^23.11.0" -pytest = "^7.4.3" -isort = "^5.12.0" +black = "^24.3.0" +pytest = "^8.1.1" +isort = "^5.13.2" python-semantic-release = "^7.32.2" -pytest-insta = "^0.2.0" +pytest-insta = "^0.3.0" [tool.poetry.scripts] lectern = "lectern.cli:main"