vim-eof-comment 0.3.10__py3-none-any.whl → 0.3.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. docs/Makefile +22 -0
  2. docs/make.bat +35 -0
  3. docs/source/conf.py +56 -0
  4. docs/source/functions.rst +2 -0
  5. docs/source/index.rst +22 -0
  6. docs/source/installation.rst +14 -0
  7. vim_eof_comment/__init__.py +2 -4
  8. vim_eof_comment/__init__.pyi +4 -3
  9. vim_eof_comment/args/parsing.py +1 -1
  10. vim_eof_comment/comments/__init__.py +2 -2
  11. vim_eof_comment/comments/__init__.pyi +1 -2
  12. vim_eof_comment/comments/filetypes.json +1 -1
  13. vim_eof_comment/comments/generator.py +28 -28
  14. vim_eof_comment/comments/generator.pyi +23 -23
  15. vim_eof_comment/eof.py +5 -8
  16. vim_eof_comment/eof.pyi +1 -1
  17. vim_eof_comment/file.py +4 -4
  18. vim_eof_comment/file.pyi +1 -1
  19. vim_eof_comment/regex.py +2 -2
  20. vim_eof_comment/regex.pyi +2 -2
  21. vim_eof_comment/types.py +86 -16
  22. vim_eof_comment/types.pyi +86 -16
  23. vim_eof_comment/util.py +1 -1
  24. vim_eof_comment/version.py +7 -3
  25. vim_eof_comment/version.pyi +4 -3
  26. {vim_eof_comment-0.3.10.dist-info → vim_eof_comment-0.3.12.dist-info}/METADATA +6 -2
  27. vim_eof_comment-0.3.12.dist-info/RECORD +39 -0
  28. {vim_eof_comment-0.3.10.dist-info → vim_eof_comment-0.3.12.dist-info}/top_level.txt +1 -0
  29. vim_eof_comment/comments/types.py +0 -76
  30. vim_eof_comment/comments/types.pyi +0 -65
  31. vim_eof_comment-0.3.10.dist-info/RECORD +0 -35
  32. {vim_eof_comment-0.3.10.dist-info → vim_eof_comment-0.3.12.dist-info}/WHEEL +0 -0
  33. {vim_eof_comment-0.3.10.dist-info → vim_eof_comment-0.3.12.dist-info}/entry_points.txt +0 -0
  34. {vim_eof_comment-0.3.10.dist-info → vim_eof_comment-0.3.12.dist-info}/licenses/LICENSE +0 -0
docs/Makefile ADDED
@@ -0,0 +1,22 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR := source
9
+ BUILDDIR := build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21
+
22
+ # vim: set ts=4 sts=4 sw=0 noet ai si sta:
docs/make.bat ADDED
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
docs/source/conf.py ADDED
@@ -0,0 +1,56 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+ """Runs configuration for building Sphinx documentation."""
6
+
7
+ import sys
8
+ from pathlib import Path
9
+ from typing import List
10
+
11
+ sys.path.insert(0, str(Path('..', 'src').resolve()))
12
+
13
+ # -- Project information -----------------------------------------------------
14
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
15
+
16
+ project: str = 'vim-eof-comment'
17
+ copyright: str = '2025, Guennadi Maximov C'
18
+ author: str = 'Guennadi Maximov C'
19
+ release: str = '0.1.33'
20
+
21
+ # -- General configuration ---------------------------------------------------
22
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
23
+
24
+ extensions: List[str] = [
25
+ 'numpydoc',
26
+ 'sphinx.ext.autodoc',
27
+ 'sphinx.ext.autosectionlabel',
28
+ 'sphinx.ext.autosummary',
29
+ 'sphinx.ext.duration',
30
+ ]
31
+
32
+ templates_path: List[str] = ['_templates']
33
+ exclude_patterns: List[str] = []
34
+
35
+ # -- Options for HTML output -------------------------------------------------
36
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
37
+
38
+ html_theme: str = 'sphinx_rtd_theme'
39
+ html_static_path: List[str] = ['_static']
40
+
41
+ # -- Options for numpydoc ----------------------------------------------------
42
+ numpydoc_xref_param_type = True
43
+ numpydoc_validation_checks = {
44
+ "all", # report on all checks, except the below
45
+ "ES01",
46
+ "EX01",
47
+ "SA01",
48
+ }
49
+ numpydoc_xref_aliases = {
50
+ 'TextIO': 'typing.TextIO',
51
+ 'List': 'list',
52
+ 'Dict': 'dict',
53
+ 'Tuple': 'tuple',
54
+ }
55
+
56
+ # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -0,0 +1,2 @@
1
+ Functions
2
+ =========
docs/source/index.rst ADDED
@@ -0,0 +1,22 @@
1
+ vim-eof-comment
2
+ ===============
3
+
4
+ **vim-eof-comment** is a Python script that adds Vim EOF comments for given filetypes in a directory.
5
+
6
+ This tool adds a `Vim modeline comment <https://neovim.io/doc/user/options.html#_2.-automatically-setting-options>`_
7
+ at the end of the target files.
8
+
9
+ .. note::
10
+ This project is under active development.
11
+
12
+ .. toctree::
13
+ :maxdepth: 2
14
+ :caption: Contents:
15
+
16
+ Contents
17
+ --------
18
+
19
+ .. toctree::
20
+
21
+ installation
22
+ functions
@@ -0,0 +1,14 @@
1
+ Installation
2
+ ============
3
+
4
+ To install *vim-eof-comment*, first install it using ``pip``:
5
+
6
+ .. code-block:: console
7
+
8
+ $ pip install -U vim-eof-comment
9
+
10
+ You may also use ``pipenv`` or any other virtual environment:
11
+
12
+ .. code-block:: console
13
+
14
+ $ pipenv install vim-eof-comment
@@ -6,6 +6,7 @@ Ensure EOF Vim comments.
6
6
  Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
7
7
  """
8
8
  __all__ = [
9
+ "__version__",
9
10
  "args",
10
11
  "comments",
11
12
  "eof",
@@ -15,13 +16,10 @@ __all__ = [
15
16
  "types",
16
17
  "util",
17
18
  "version",
18
- "version_info",
19
19
  ]
20
20
 
21
21
  from . import args, comments, eof, file, regex, types, util
22
22
  from .eof import main
23
- from .version import version_info
24
-
25
- version: str = str(version_info)
23
+ from .version import __version__
26
24
 
27
25
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -6,10 +6,11 @@ from . import regex as regex
6
6
  from . import types as types
7
7
  from . import util as util
8
8
  from .eof import main as main
9
- from .version import version_info as version_info
9
+ from .version import __version__ as __version__
10
10
 
11
- __all__ = ['args', 'comments', 'eof', 'file', 'main', 'regex', 'types', 'util', 'version', 'version_info']
11
+ __all__ = ['__version__', 'args', 'comments', 'eof', 'file', 'main', 'regex', 'types', 'util', 'version']
12
12
 
13
- version: str
13
+ # Names in __all__ with no definition:
14
+ # version
14
15
 
15
16
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -220,7 +220,7 @@ def indent_handler(indent: str) -> List[IndentHandler]:
220
220
  if len(inds) >= 3 and inds[2].upper() in ("Y", "N"):
221
221
  et = not inds[2].upper() == "N"
222
222
 
223
- maps.append(IndentHandler(ext=ext, level=ind_level, expandtab=et))
223
+ maps.append(IndentHandler(ft_ext=ext, level=ind_level, expandtab=et))
224
224
 
225
225
  return maps
226
226
 
@@ -5,8 +5,8 @@ Comment class module for ``vim-eof-comment``.
5
5
 
6
6
  Copyright (c) 2025 Guennadi Maximov C. All Rights Reserved.
7
7
  """
8
- __all__ = ["generator", "types"]
8
+ __all__ = ["generator"]
9
9
 
10
- from . import generator, types
10
+ from . import generator
11
11
 
12
12
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -1,6 +1,5 @@
1
1
  from . import generator as generator
2
- from . import types as types
3
2
 
4
- __all__ = ['generator', 'types']
3
+ __all__ = ['generator']
5
4
 
6
5
  # vim: set ts=4 sts=4 sw=4 et ai si sta:
@@ -1 +1 @@
1
- [{"C": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "H": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "Makefile": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "bash": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "c": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "cc": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "cpp": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "css": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "fish": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "h": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "hh": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "hpp": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "htm": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "html": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "latex": "% vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "lua": "-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "markdown": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "md": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "mk": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "py": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "pyi": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "rb": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "sh": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "tex": "% vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "xml": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "zsh": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:"}, {"C": {"level": 2, "expandtab": true}, "H": {"level": 2, "expandtab": true}, "Makefile": {"level": 4, "expandtab": false}, "bash": {"level": 4, "expandtab": true}, "c": {"level": 2, "expandtab": true}, "cc": {"level": 2, "expandtab": true}, "cpp": {"level": 2, "expandtab": true}, "css": {"level": 4, "expandtab": true}, "fish": {"level": 4, "expandtab": true}, "h": {"level": 2, "expandtab": true}, "hh": {"level": 2, "expandtab": true}, "hpp": {"level": 2, "expandtab": true}, "htm": {"level": 2, "expandtab": true}, "html": {"level": 2, "expandtab": true}, "latex": {"level": 2, "expandtab": true}, "lua": {"level": 4, "expandtab": true}, "markdown": {"level": 2, "expandtab": true}, "md": {"level": 2, "expandtab": true}, "mk": {"level": 4, "expandtab": false}, "py": {"level": 4, "expandtab": true}, "pyi": {"level": 4, "expandtab": true}, "rb": {"level": 4, "expandtab": true}, "sh": {"level": 4, "expandtab": true}, "tex": {"level": 2, "expandtab": true}, "xml": {"level": 2, "expandtab": true}, "zsh": {"level": 4, "expandtab": true}}]
1
+ [{ "C": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "H": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "Makefile": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "bash": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "c": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "cc": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "cpp": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "css": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "fish": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "h": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "hh": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "hpp": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "htm": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "html": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "javascript": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "javascriptreact": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "js": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "jsx": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "latex": "% vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "lua": "-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "make": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "markdown": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "md": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "mk": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "py": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "pyi": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "python": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "rb": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "rs": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "ruby": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "rust": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "sh": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "tex": "% vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "toml": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "ts": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "tsx": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "typescript": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "typescriptreact": "/* vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: */", "xhtml": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "xml": "<!-- vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta: -->", "yaml": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "yml": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:", "zsh": "# vim: set ts={ts} sts={sts} sw={sw} {et} ai si sta:" }, { "C": { "level": 2, "expandtab": true }, "H": { "level": 2, "expandtab": true }, "Makefile": { "level": 4, "expandtab": false }, "bash": { "level": 4, "expandtab": true }, "c": { "level": 2, "expandtab": true }, "cc": { "level": 2, "expandtab": true }, "cpp": { "level": 2, "expandtab": true }, "css": { "level": 4, "expandtab": true }, "fish": { "level": 4, "expandtab": true }, "h": { "level": 2, "expandtab": true }, "hh": { "level": 2, "expandtab": true }, "hpp": { "level": 2, "expandtab": true }, "htm": { "level": 2, "expandtab": true }, "html": { "level": 2, "expandtab": true }, "javascript": { "level": 4, "expandtab": true }, "javascriptreact": { "level": 4, "expandtab": true }, "js": { "level": 4, "expandtab": true }, "jsx": { "level": 4, "expandtab": true }, "latex": { "level": 2, "expandtab": true }, "lua": { "level": 4, "expandtab": true }, "make": { "level": 4, "expandtab": false }, "markdown": { "level": 2, "expandtab": true }, "md": { "level": 2, "expandtab": true }, "mk": { "level": 4, "expandtab": false }, "py": { "level": 4, "expandtab": true }, "pyi": { "level": 4, "expandtab": true }, "python": { "level": 4, "expandtab": true }, "rb": { "level": 2, "expandtab": true }, "rs": { "level": 4, "expandtab": true }, "ruby": { "level": 2, "expandtab": true }, "rust": { "level": 4, "expandtab": true }, "sh": { "level": 4, "expandtab": true }, "tex": { "level": 2, "expandtab": true }, "toml": { "level": 4, "expandtab": true }, "ts": { "level": 4, "expandtab": true }, "tsx": { "level": 4, "expandtab": true }, "typescript": { "level": 4, "expandtab": true }, "typescriptreact": { "level": 4, "expandtab": true }, "xhtml": { "level": 2, "expandtab": true }, "xml": { "level": 2, "expandtab": true }, "yaml": { "level": 2, "expandtab": true }, "yml": { "level": 2, "expandtab": true }, "zsh": { "level": 4, "expandtab": true } }]
@@ -13,22 +13,22 @@ from io import TextIOWrapper
13
13
  from os.path import exists, isdir, realpath
14
14
  from typing import Dict, Iterator, List, NoReturn, Tuple
15
15
 
16
+ from ..types import IndentMap
16
17
  from ..util import die
17
- from .types import GeneratedEOFComments, IndentMapDict
18
18
 
19
19
  _JSON_FILE: str = realpath("./vim_eof_comment/comments/filetypes.json")
20
20
 
21
21
 
22
- def import_json() -> Tuple[GeneratedEOFComments, IndentMapDict]:
22
+ def import_json() -> Tuple[Dict[str, str], Dict[str, IndentMap]]:
23
23
  """
24
24
  Import default vars from JSON file.
25
25
 
26
26
  Returns
27
27
  -------
28
- comments : GeneratedEOFComments
29
- The default ``GeneratedEOFComments``.
30
- map_dict : IndentMapDict
31
- The default ``IndentMapDict``.
28
+ comments : Dict[str, str]
29
+ The default ``Dict[str, str]``.
30
+ map_dict : Dict[str, IndentMap]
31
+ The default indent mappings dict.
32
32
  """
33
33
  splitter: str = "/" if os.name != "nt" else "\\"
34
34
  split = __file__.split(splitter)
@@ -39,7 +39,7 @@ def import_json() -> Tuple[GeneratedEOFComments, IndentMapDict]:
39
39
  data: str = "".join(file.read().split("\n"))
40
40
  file.close()
41
41
 
42
- result: Tuple[GeneratedEOFComments, IndentMapDict] = json.loads(data)
42
+ result: Tuple[Dict[str, str], Dict[str, IndentMap]] = json.loads(data)
43
43
 
44
44
  return result[0], result[1]
45
45
 
@@ -53,18 +53,18 @@ class Comments():
53
53
 
54
54
  Parameters
55
55
  ----------
56
- mappings : IndentMapDict, optional, default=None
56
+ mappings : Dict[str, IndentMap], optional, default=None
57
57
  The ``str`` to ``IndentMap`` dictionary.
58
58
 
59
59
  Attributes
60
60
  ----------
61
- __DEFAULT : IndentMapDict
61
+ __DEFAULT : Dict[str, IndentMap]
62
62
  The default/fallback alternative to ``langs``.
63
- __formats : GeneratedEOFComments
63
+ __formats : Dict[str, str]
64
64
  The default/fallback alternative to ``comments``.
65
- langs : IndentMapDict
65
+ langs : Dict[str, IndentMap]
66
66
  A dictionary of ``IndentMap`` type objects.
67
- comments : GeneratedEOFComments
67
+ comments : Dict[str, str]
68
68
  A dictionary of file-extension-to-EOF-comment mappings.
69
69
 
70
70
  Methods
@@ -74,18 +74,18 @@ class Comments():
74
74
  get_defaults()
75
75
  """
76
76
 
77
- __DEFAULT: IndentMapDict = _DEFAULT.copy()
78
- __formats: GeneratedEOFComments = _formats.copy()
79
- comments: GeneratedEOFComments
80
- langs: IndentMapDict
77
+ __DEFAULT: Dict[str, IndentMap] = _DEFAULT.copy()
78
+ __formats: Dict[str, str] = _formats.copy()
79
+ comments: Dict[str, str]
80
+ langs: Dict[str, IndentMap]
81
81
 
82
- def __init__(self, mappings: IndentMapDict | None = None):
82
+ def __init__(self, mappings: Dict[str, IndentMap] | None = None):
83
83
  """
84
84
  Create a new Vim EOF comment object.
85
85
 
86
86
  Parameters
87
87
  ----------
88
- mappings : IndentMapDict, optional, default=None
88
+ mappings : Dict[str, IndentMap], optional, default=None
89
89
  The ``str`` to ``IndentMap`` dictionary.
90
90
  """
91
91
  if mappings is None or len(mappings) == 0:
@@ -126,13 +126,13 @@ class Comments():
126
126
  """
127
127
  return lang in self.__DEFAULT.keys()
128
128
 
129
- def __fill_langs(self, langs: IndentMapDict) -> NoReturn:
129
+ def __fill_langs(self, langs: Dict[str, IndentMap]) -> NoReturn:
130
130
  """
131
131
  Fill languages dict.
132
132
 
133
133
  Parameters
134
134
  ----------
135
- langs : IndentMapDict
135
+ langs : Dict[str, IndentMap]
136
136
  A dictionary of ``IndentMap`` type objects.
137
137
  """
138
138
  if len(langs) == 0:
@@ -142,26 +142,26 @@ class Comments():
142
142
  for lang, mapping in self.__DEFAULT.items():
143
143
  langs[lang] = langs.get(lang, mapping)
144
144
 
145
- self.langs = IndentMapDict(**langs)
145
+ self.langs = langs.copy()
146
146
 
147
- def get_defaults(self) -> IndentMapDict:
147
+ def get_defaults(self) -> Dict[str, IndentMap]:
148
148
  """
149
149
  Retrieve the default comment dictionary.
150
150
 
151
151
  Returns
152
152
  -------
153
- IndentMapDict
153
+ Dict[str, IndentMap]
154
154
  A dictionary of ``IndentMap`` type objects.
155
155
  """
156
156
  return self.__DEFAULT
157
157
 
158
- def generate(self) -> GeneratedEOFComments:
158
+ def generate(self) -> Dict[str, str]:
159
159
  """
160
160
  Generate the comments list.
161
161
 
162
162
  Returns
163
163
  -------
164
- GeneratedEOFComments
164
+ Dict[str, str]
165
165
  The customly generated comments dictionary.
166
166
  """
167
167
  comments: Dict[str, str] = dict()
@@ -174,7 +174,7 @@ class Comments():
174
174
 
175
175
  comments[lang] = fmt.format(ts=lvl, sts=lvl, sw=sw, et=et)
176
176
 
177
- self.comments: GeneratedEOFComments = GeneratedEOFComments(**comments)
177
+ self.comments: Dict[str, str] = comments.copy()
178
178
  return self.comments
179
179
 
180
180
  def get_ft(self, ext: str) -> str | None:
@@ -191,7 +191,7 @@ class Comments():
191
191
  str or None
192
192
  Either the file extension string, or if not available then ``None``.
193
193
  """
194
- comments: GeneratedEOFComments = self.generate()
194
+ comments: Dict[str, str] = self.generate()
195
195
  return comments.get(ext, None)
196
196
 
197
197
 
@@ -200,7 +200,7 @@ def list_filetypes() -> NoReturn:
200
200
  txt: List[str] = [""]
201
201
 
202
202
  c: Comments = Comments()
203
- defaults: IndentMapDict = c.get_defaults()
203
+ defaults: Dict[str, IndentMap] = c.get_defaults()
204
204
  for ext, indents in defaults.items():
205
205
  txt.append(f"- {ext}: {indents}")
206
206
 
@@ -1,19 +1,19 @@
1
1
  from typing import Iterator, NoReturn
2
2
 
3
- from .types import GeneratedEOFComments, IndentMapDict
3
+ from ..types import IndentMap
4
4
 
5
5
  __all__ = ['Comments', 'export_json', 'import_json', 'list_filetypes']
6
6
 
7
- def import_json() -> tuple[GeneratedEOFComments, IndentMapDict]:
7
+ def import_json() -> tuple[dict[str, str], dict[str, IndentMap]]:
8
8
  """
9
9
  Import default vars from JSON file.
10
10
 
11
11
  Returns
12
12
  -------
13
- comments : GeneratedEOFComments
14
- The default ``GeneratedEOFComments``.
15
- map_dict : IndentMapDict
16
- The default ``IndentMapDict``.
13
+ comments : Dict[str, str]
14
+ The default ``Dict[str, str]``.
15
+ map_dict : Dict[str, IndentMap]
16
+ The default indent mappings dict.
17
17
  """
18
18
 
19
19
  class Comments:
@@ -22,18 +22,18 @@ class Comments:
22
22
 
23
23
  Parameters
24
24
  ----------
25
- mappings : IndentMapDict, optional, default=None
25
+ mappings : Dict[str, IndentMap], optional, default=None
26
26
  The ``str`` to ``IndentMap`` dictionary.
27
27
 
28
28
  Attributes
29
29
  ----------
30
- __DEFAULT : IndentMapDict
30
+ __DEFAULT : Dict[str, IndentMap]
31
31
  The default/fallback alternative to ``langs``.
32
- __formats : GeneratedEOFComments
32
+ __formats : Dict[str, str]
33
33
  The default/fallback alternative to ``comments``.
34
- langs : IndentMapDict
34
+ langs : Dict[str, IndentMap]
35
35
  A dictionary of ``IndentMap`` type objects.
36
- comments : GeneratedEOFComments
36
+ comments : Dict[str, str]
37
37
  A dictionary of file-extension-to-EOF-comment mappings.
38
38
 
39
39
  Methods
@@ -42,17 +42,17 @@ class Comments:
42
42
  __fill_langs(langs)
43
43
  get_defaults()
44
44
  """
45
- __DEFAULT: IndentMapDict
46
- __formats: GeneratedEOFComments
47
- comments: GeneratedEOFComments
48
- langs: IndentMapDict
49
- def __init__(self, mappings: IndentMapDict | None = None) -> None:
45
+ __DEFAULT: dict[str, IndentMap]
46
+ __formats: dict[str, str]
47
+ comments: dict[str, str]
48
+ langs: dict[str, IndentMap]
49
+ def __init__(self, mappings: dict[str, IndentMap] | None = None) -> None:
50
50
  """
51
51
  Create a new Vim EOF comment object.
52
52
 
53
53
  Parameters
54
54
  ----------
55
- mappings : IndentMapDict, optional, default=None
55
+ mappings : Dict[str, IndentMap], optional, default=None
56
56
  The ``str`` to ``IndentMap`` dictionary.
57
57
  """
58
58
  def __iter__(self) -> Iterator[str]:
@@ -71,31 +71,31 @@ class Comments:
71
71
  bool
72
72
  Represents whether the file extension has been included in the defaults.
73
73
  """
74
- def __fill_langs(self, langs: IndentMapDict) -> NoReturn:
74
+ def __fill_langs(self, langs: dict[str, IndentMap]) -> NoReturn:
75
75
  """
76
76
  Fill languages dict.
77
77
 
78
78
  Parameters
79
79
  ----------
80
- langs : IndentMapDict
80
+ langs : Dict[str, IndentMap]
81
81
  A dictionary of ``IndentMap`` type objects.
82
82
  """
83
- def get_defaults(self) -> IndentMapDict:
83
+ def get_defaults(self) -> dict[str, IndentMap]:
84
84
  """
85
85
  Retrieve the default comment dictionary.
86
86
 
87
87
  Returns
88
88
  -------
89
- IndentMapDict
89
+ Dict[str, IndentMap]
90
90
  A dictionary of ``IndentMap`` type objects.
91
91
  """
92
- def generate(self) -> GeneratedEOFComments:
92
+ def generate(self) -> dict[str, str]:
93
93
  """
94
94
  Generate the comments list.
95
95
 
96
96
  Returns
97
97
  -------
98
- GeneratedEOFComments
98
+ Dict[str, str]
99
99
  The customly generated comments dictionary.
100
100
  """
101
101
  def get_ft(self, ext: str) -> str | None:
vim_eof_comment/eof.py CHANGED
@@ -20,7 +20,7 @@ from .file import bootstrap_paths, get_last_line, modify_file, open_batch_paths
20
20
  from .regex import matches
21
21
  from .types import BatchPathDict, EOFCommentSearch, IndentHandler, IOWrapperBool
22
22
  from .util import die, gen_indent_maps, verbose_print, version_print
23
- from .version import list_versions, version_info
23
+ from .version import __version__, list_versions
24
24
 
25
25
  _RED: int = Fore.LIGHTRED_EX
26
26
  _GREEN: int = Fore.LIGHTGREEN_EX
@@ -41,7 +41,7 @@ def eof_comment_search(
41
41
  files : Dict[str, BatchPathDict]
42
42
  A dictionary of ``str`` to ``BatchPathDict`` objects.
43
43
  comments : Comments
44
- The ``Comments`` object containing the hardcoded comments per file extension.
44
+ The ``Comments`` object containing the hardcoded comments per file-type/file-extension.
45
45
  **kwargs
46
46
  COntains the ``verbose`` and ``newline`` boolean options.
47
47
 
@@ -68,7 +68,7 @@ def eof_comment_search(
68
68
  verbose_print(f"{_RESET}Analyzing files...\n", verbose=verbose)
69
69
  for path, file in files.items():
70
70
  file_obj: TextIOWrapper = file["file"]
71
- ext: str = file["ext"]
71
+ ext: str = file["ft_ext"]
72
72
 
73
73
  wrapper = get_last_line(file_obj)
74
74
  last_line, has_nwl = wrapper["line"], wrapper["has_nwl"]
@@ -139,7 +139,7 @@ def main() -> int:
139
139
  parser, ns = arg_parser_init()
140
140
 
141
141
  if ns.version:
142
- version_print(str(version_info))
142
+ version_print(__version__)
143
143
 
144
144
  if ns.list_fts:
145
145
  list_filetypes()
@@ -161,15 +161,12 @@ def main() -> int:
161
161
  if dry_run:
162
162
  verbose = True
163
163
 
164
- indent = gen_indent_maps(indent.copy())
165
-
166
- comments = Comments(indent)
167
-
168
164
  files = open_batch_paths(bootstrap_paths(dirs, exts))
169
165
  if len(files) == 0:
170
166
  code = 1 if not dry_run else 0
171
167
  die("No matching files found!", code=code)
172
168
 
169
+ comments = Comments(gen_indent_maps(indent.copy()))
173
170
  results = eof_comment_search(files, comments, verbose=verbose, newline=newline)
174
171
  if len(results) > 0 and not dry_run:
175
172
  append_eof_comment(results, comments, newline)
vim_eof_comment/eof.pyi CHANGED
@@ -14,7 +14,7 @@ def eof_comment_search(files: dict[str, BatchPathDict], comments: Comments, **kw
14
14
  files : Dict[str, BatchPathDict]
15
15
  A dictionary of ``str`` to ``BatchPathDict`` objects.
16
16
  comments : Comments
17
- The ``Comments`` object containing the hardcoded comments per file extension.
17
+ The ``Comments`` object containing the hardcoded comments per file-type/file-extension.
18
18
  **kwargs
19
19
  COntains the ``verbose`` and ``newline`` boolean options.
20
20
 
vim_eof_comment/file.py CHANGED
@@ -44,7 +44,7 @@ def bootstrap_paths(paths: List[str], exts: List[str]) -> List[BatchPairDict]:
44
44
  if not file.endswith(ext):
45
45
  continue
46
46
 
47
- result.append(BatchPairDict(fpath=join(root, file), ext=ext))
47
+ result.append(BatchPairDict(fpath=join(root, file), ft_ext=ext))
48
48
 
49
49
  return result
50
50
 
@@ -65,9 +65,9 @@ def open_batch_paths(paths: List[BatchPairDict]) -> Dict[str, BatchPathDict]:
65
65
  """
66
66
  result = dict()
67
67
  for path in paths:
68
- fpath, ext = path["fpath"], path["ext"]
68
+ fpath, ext = path["fpath"], path["ft_ext"]
69
69
  try:
70
- result[fpath] = {"file": open(fpath, "r"), "ext": ext}
70
+ result[fpath] = {"file": open(fpath, "r"), "ft_ext": ext}
71
71
  except KeyboardInterrupt:
72
72
  die("\nProgram interrupted!", code=1) # Kills the program
73
73
  except FileNotFoundError:
@@ -89,7 +89,7 @@ def modify_file(file: TextIOWrapper, comments: Dict[str, str], ext: str, **kwarg
89
89
  comments : Dict[str, str]
90
90
  A filetype-to-comment dictionary.
91
91
  ext : str
92
- The filetype extension given by the user.
92
+ The file-type/file-extension given by the user.
93
93
  **kwargs
94
94
  Contains the ``newline``, and ``matching`` boolean attributes.
95
95
 
vim_eof_comment/file.pyi CHANGED
@@ -45,7 +45,7 @@ def modify_file(file: TextIOWrapper, comments: dict[str, str], ext: str, **kwarg
45
45
  comments : Dict[str, str]
46
46
  A filetype-to-comment dictionary.
47
47
  ext : str
48
- The filetype extension given by the user.
48
+ The file-type/file-extension given by the user.
49
49
  **kwargs
50
50
  Contains the ``newline``, and ``matching`` boolean attributes.
51
51
 
vim_eof_comment/regex.py CHANGED
@@ -11,7 +11,7 @@ from re import compile
11
11
  from typing import Tuple
12
12
 
13
13
 
14
- def matches(s: str, verbose: bool) -> bool:
14
+ def matches(s: str, verbose: bool = False) -> bool:
15
15
  """
16
16
  Check if given string matches any of the given patterns.
17
17
 
@@ -19,7 +19,7 @@ def matches(s: str, verbose: bool) -> bool:
19
19
  ----------
20
20
  s : str
21
21
  The string to be matched.
22
- verbose : bool
22
+ verbose : bool, optional, default=False
23
23
  Enables verbose mode.
24
24
 
25
25
  Returns
vim_eof_comment/regex.pyi CHANGED
@@ -1,6 +1,6 @@
1
1
  __all__ = ['matches']
2
2
 
3
- def matches(s: str, verbose: bool) -> bool:
3
+ def matches(s: str, verbose: bool = False) -> bool:
4
4
  """
5
5
  Check if given string matches any of the given patterns.
6
6
 
@@ -8,7 +8,7 @@ def matches(s: str, verbose: bool) -> bool:
8
8
  ----------
9
9
  s : str
10
10
  The string to be matched.
11
- verbose : bool
11
+ verbose : bool, optional, default=False
12
12
  Enables verbose mode.
13
13
 
14
14
  Returns