rstcheck / rstcheck-core

Core library behind rstcheck.
http://rstcheck-core.rtfd.io/
MIT License
4 stars 8 forks source link

[Bug]: fix incompatibility with py 3.11 #21

Closed Cielquan closed 2 years ago

Cielquan commented 2 years ago

To Dos

Example Code (python)

-

Relevant log output

rstcheck --config testing/examples/with_configuration/bad_config.toml testing/examples/good/rst.rst 
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/krys/Projects/.contributions/rstcheck/src/rstcheck/_cli.py:137 in cli                      │
│                                                                                                  │
│   134 │                                                                                          │
│   135 │   try:                                                                                   │
│   136 │   │   logger.debug("Create main runner instance.")                                       │
│ ❱ 137 │   │   _runner = runner.RstcheckMainRunner(                                               │
│   138 │   │   │   check_paths=files, rstcheck_config=rstcheck_config, overwrite_config=False     │
│   139 │   │   )                                                                                  │
│   140 │   │   logger.info("Run main runner instance.")                                           │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │                config = PosixPath('testing/examples/with_configuration/bad_config.toml')     │ │
│ │             exit_code = 1                                                                    │ │
│ │                 files = [PosixPath('testing/examples/good/rst.rst')]                         │ │
│ │     ignore_directives = None                                                                 │ │
│ │      ignore_languages = None                                                                 │ │
│ │       ignore_messages = None                                                                 │ │
│ │          ignore_roles = None                                                                 │ │
│ │  ignore_substitutions = None                                                                 │ │
│ │             log_level = 'WARNING'                                                            │ │
│ │                logger = <Logger rstcheck._cli (WARNING)>                                     │ │
│ │             recursive = None                                                                 │ │
│ │          report_level = None                                                                 │ │
│ │       rstcheck_config = RstcheckConfig(                                                      │ │
│ │                         │   report_level=None,                                               │ │
│ │                         │   ignore_directives=None,                                          │ │
│ │                         │   ignore_roles=None,                                               │ │
│ │                         │   ignore_substitutions=None,                                       │ │
│ │                         │   ignore_languages=None,                                           │ │
│ │                         │   ignore_messages=None,                                            │ │
│ │                         │                                                                    │ │
│ │                         config_path=PosixPath('testing/examples/with_configuration/bad_conf… │ │
│ │                         │   recursive=None,                                                  │ │
│ │                         │   warn_unknown_settings=None                                       │ │
│ │                         )                                                                    │ │
│ │               version = None                                                                 │ │
│ │ warn_unknown_settings = None                                                                 │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/krys/Projects/.contributions/rstcheck/.venv311/lib/python3.11/site-packages/rstcheck_core/ │
│ runner.py:34 in __init__                                                                         │
│                                                                                                  │
│    31 │   │   self.config = rstcheck_config                                                      │
│    32 │   │   self.overwrite_config = overwrite_config                                           │
│    33 │   │   if rstcheck_config.config_path:                                                    │
│ ❱  34 │   │   │   self.load_config_file(                                                         │
│    35 │   │   │   │   rstcheck_config.config_path, rstcheck_config.warn_unknown_settings or Fa   │
│    36 │   │   │   )                                                                              │
│    37                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │      check_paths = [PosixPath('testing/examples/good/rst.rst')]                              │ │
│ │ overwrite_config = False                                                                     │ │
│ │  rstcheck_config = RstcheckConfig(                                                           │ │
│ │                    │   report_level=None,                                                    │ │
│ │                    │   ignore_directives=None,                                               │ │
│ │                    │   ignore_roles=None,                                                    │ │
│ │                    │   ignore_substitutions=None,                                            │ │
│ │                    │   ignore_languages=None,                                                │ │
│ │                    │   ignore_messages=None,                                                 │ │
│ │                    │                                                                         │ │
│ │                    config_path=PosixPath('testing/examples/with_configuration/bad_config.to… │ │
│ │                    │   recursive=None,                                                       │ │
│ │                    │   warn_unknown_settings=None                                            │ │
│ │                    )                                                                         │ │
│ │             self = <rstcheck_core.runner.RstcheckMainRunner object at 0x7fdfec298750>        │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/krys/Projects/.contributions/rstcheck/.venv311/lib/python3.11/site-packages/rstcheck_core/ │
│ runner.py:79 in load_config_file                                                                 │
│                                                                                                  │
│    76 │   │   │   defaults to :py:obj:`False`                                                    │
│    77 │   │   """                                                                                │
│    78 │   │   logger.info(f"Load config file for main runner: '{config_path}'.")                 │
│ ❱  79 │   │   file_config = config.load_config_file_from_path(                                   │
│    80 │   │   │   config_path, warn_unknown_settings=warn_unknown_settings                       │
│    81 │   │   )                                                                                  │
│    82                                                                                            │
│                                                                                                  │
│ ╭────────────────────────────────────────── locals ──────────────────────────────────────────╮   │
│ │           config_path = PosixPath('testing/examples/with_configuration/bad_config.toml')   │   │
│ │                  self = <rstcheck_core.runner.RstcheckMainRunner object at 0x7fdfec298750> │   │
│ │ warn_unknown_settings = False                                                              │   │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────╯   │
│                                                                                                  │
│ /home/krys/Projects/.contributions/rstcheck/.venv311/lib/python3.11/site-packages/rstcheck_core/ │
│ config.py:522 in load_config_file_from_path                                                      │
│                                                                                                  │
│   519 │   resolved_path = path.resolve()                                                         │
│   520 │                                                                                          │
│   521 │   if resolved_path.is_file():                                                            │
│ ❱ 522 │   │   return load_config_file(                                                           │
│   523 │   │   │   resolved_path,                                                                 │
│   524 │   │   │   log_missing_section_as_warning=log_missing_section_as_warning_for_file,        │
│   525 │   │   │   warn_unknown_settings=warn_unknown_settings,                                   │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │  log_missing_section_as_warning_for_dir = False                                              │ │
│ │ log_missing_section_as_warning_for_file = True                                               │ │
│ │                                    path = PosixPath('testing/examples/with_configuration/ba… │ │
│ │                           resolved_path = PosixPath('/home/krys/Projects/.contributions/rst… │ │
│ │                         search_dir_tree = False                                              │ │
│ │                   warn_unknown_settings = False                                              │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/krys/Projects/.contributions/rstcheck/.venv311/lib/python3.11/site-packages/rstcheck_core/ │
│ config.py:367 in load_config_file                                                                │
│                                                                                                  │
│   364 │   │   return None                                                                        │
│   365 │                                                                                          │
│   366 │   if file_path.suffix.casefold() == ".toml":                                             │
│ ❱ 367 │   │   return _load_config_from_toml_file(                                                │
│   368 │   │   │   file_path,                                                                     │
│   369 │   │   │   log_missing_section_as_warning=log_missing_section_as_warning,                 │
│   370 │   │   │   warn_unknown_settings=warn_unknown_settings,                                   │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │                      file_path = PosixPath('/home/krys/Projects/.contributions/rstcheck/tes… │ │
│ │ log_missing_section_as_warning = True                                                        │ │
│ │          warn_unknown_settings = False                                                       │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/krys/Projects/.contributions/rstcheck/.venv311/lib/python3.11/site-packages/rstcheck_core/ │
│ config.py:295 in _load_config_from_toml_file                                                     │
│                                                                                                  │
│   292 │   :return: instance of :py:class:`RstcheckConfigFile` or :py:obj:`None` on missing con   │
│   293 │   │   or ``NONE`` is passed as the config path.                                          │
│   294 │   """                                                                                    │
│ ❱ 295 │   _extras.install_guard("tomli")                                                         │
│   296 │   logger.debug(f"Try loading config from TOML file: '{toml_file}'.")                     │
│   297 │                                                                                          │
│   298 │   if toml_file.name == "NONE":                                                           │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ log_missing_section_as_warning = True                                                        │ │
│ │                      toml_file = PosixPath('/home/krys/Projects/.contributions/rstcheck/tes… │ │
│ │          warn_unknown_settings = False                                                       │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/krys/Projects/.contributions/rstcheck/.venv311/lib/python3.11/site-packages/rstcheck_core/ │
│ _extras.py:90 in install_guard                                                                   │
│                                                                                                  │
│   87 │                                                                                           │
│   88 │   extra = ExtraDependenciesInfos[package]                                                 │
│   89 │                                                                                           │
│ ❱ 90 │   raise ModuleNotFoundError(                                                              │
│   91 │   │   f"No supported version of {package} installed. "                                    │
│   92 │   │   f"Install rstcheck with {extra} extra (rstcheck[{extra}]) or "                      │
│   93 │   │   f"install a supported version of {package} yourself."                               │
│                                                                                                  │
│ ╭────────────────────── locals ──────────────────────╮                                           │
│ │   extra = {'min_version': (2, 0), 'extra': 'toml'} │                                           │
│ │ package = 'tomli'                                  │                                           │
│ ╰────────────────────────────────────────────────────╯                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ModuleNotFoundError: No supported version of tomli installed. Install rstcheck with {'min_version': (2, 0), 'extra': 'toml'} extra (rstcheck[{'min_version': (2, 0), 'extra': 'toml'}]) or install a supported version of tomli yourself.
*** Exit Code: 1 ***
| (╯°□°)╯︵ ┻━┻ ... Exit Code: 1

Description

When running tests over in rstcheck with py 3.11 tests are failing because of issues with toml lib versions.

Therefore I plan to use py 3.11's tomllib with >3.11.

Operating System

Other

Operating System Details

No response

Python Version

3.11

rstcheck Version

v1.0.2

Additional Context

No response