From 793af9951afac1bbc406a970536029b19ace65fd Mon Sep 17 00:00:00 2001 From: gnikit Date: Sun, 14 Apr 2024 23:23:29 +0100 Subject: [PATCH 1/2] chore: update encoding to utf-8 when creating schema file --- fortls/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortls/schema.py b/fortls/schema.py index d1d0e89b..e9e7267a 100644 --- a/fortls/schema.py +++ b/fortls/schema.py @@ -28,7 +28,7 @@ def create_schema(root: pathlib.Path | None = None): m = create_model("fortls schema", **only_vals) m.__doc__ = "Schema for the fortls Fortran Language Server" - with open(str(root / "fortls.schema.json"), "w") as f: + with open(str(root / "fortls.schema.json"), "w", encoding="utf-8") as f: print(m.schema_json(indent=2), file=f) print(f"Created schema file: {root / 'fortls.schema.json'}") From 80ded619ea4ced6623b9b05762092b0e032a8e8c Mon Sep 17 00:00:00 2001 From: gnikit Date: Sun, 14 Apr 2024 23:33:41 +0100 Subject: [PATCH 2/2] chore: update pydantic dependency to version 2x --- fortls/fortls.schema.json | 134 +++++++++++++++++++------------------- fortls/schema.py | 5 +- setup.cfg | 2 +- 3 files changed, 71 insertions(+), 70 deletions(-) diff --git a/fortls/fortls.schema.json b/fortls/fortls.schema.json index 21d421db..62b434d7 100644 --- a/fortls/fortls.schema.json +++ b/fortls/fortls.schema.json @@ -1,193 +1,193 @@ { - "title": "fortls schema", "description": "Schema for the fortls Fortran Language Server", - "type": "object", "properties": { "config": { - "title": "Config", - "description": "Configuration options file (default file name: .fortlsrc, other default supported names: .fortls.json, .fortls)", "default": ".fortlsrc", + "description": "Configuration options file (default file name: .fortlsrc, other default supported names: .fortls.json, .fortls)", + "title": "Config", "type": "string" }, "nthreads": { - "title": "Nthreads", - "description": "Number of threads to use during workspace initialization (default: 4)", "default": 4, + "description": "Number of threads to use during workspace initialization (default: 4)", + "title": "Nthreads", "type": "integer" }, "notify_init": { - "title": "Notify Init", - "description": "Send notification message when workspace initialization is complete", "default": false, + "description": "Send notification message when workspace initialization is complete", + "title": "Notify Init", "type": "boolean" }, "incremental_sync": { - "title": "Incremental Sync", - "description": "Use incremental document synchronization (beta)", "default": false, + "description": "Use incremental document synchronization (beta)", + "title": "Incremental Sync", "type": "boolean" }, "recursion_limit": { - "title": "Recursion Limit", - "description": "Set the maximum recursion depth for the parser (default: 1000)", "default": 1000, + "description": "Set the maximum recursion depth for the parser (default: 1000)", + "title": "Recursion Limit", "type": "integer" }, "sort_keywords": { - "title": "Sort Keywords", - "description": "Display variable keywords information, function/subroutine definitions, etc. in a consistent (sorted) manner default: no sorting, display code as is)", "default": false, + "description": "Display variable keywords information, function/subroutine definitions, etc. in a consistent (sorted) manner default: no sorting, display code as is)", + "title": "Sort Keywords", "type": "boolean" }, "disable_autoupdate": { - "title": "Disable Autoupdate", - "description": "fortls automatically checks PyPi for newer version and installs them.Use this option to disable the autoupdate feature.", "default": false, + "description": "fortls automatically checks PyPi for newer version and installs them.Use this option to disable the autoupdate feature.", + "title": "Disable Autoupdate", "type": "boolean" }, "preserve_keyword_order": { - "title": "Preserve Keyword Order", - "description": "DEPRECATED, this is now the default. To sort use sort_keywords", "default": false, + "description": "DEPRECATED, this is now the default. To sort use sort_keywords", + "title": "Preserve Keyword Order", "type": "boolean" }, "debug_log": { - "title": "Debug Log", - "description": "Generate debug log in project root folder", "default": false, + "description": "Generate debug log in project root folder", + "title": "Debug Log", "type": "boolean" }, "source_dirs": { - "title": "Source Dirs", - "description": "Folders containing source files (default: set())", "default": [], - "type": "array", + "description": "Folders containing source files (default: set())", "items": {}, + "title": "Source Dirs", + "type": "array", "uniqueItems": true }, "incl_suffixes": { - "title": "Incl Suffixes", - "description": "Consider additional file extensions to the default (default: .F, .F77, .F90, .F95, .F03, .F08, .FOR, .FPP (lower & upper casing))", "default": [], - "type": "array", + "description": "Consider additional file extensions to the default (default: .F, .F77, .F90, .F95, .F03, .F08, .FOR, .FPP (lower & upper casing))", "items": {}, + "title": "Incl Suffixes", + "type": "array", "uniqueItems": true }, "excl_suffixes": { - "title": "Excl Suffixes", - "description": "Source file extensions to be excluded (default: set())", "default": [], - "type": "array", + "description": "Source file extensions to be excluded (default: set())", "items": {}, + "title": "Excl Suffixes", + "type": "array", "uniqueItems": true }, "excl_paths": { - "title": "Excl Paths", - "description": "Folders to exclude from parsing", "default": [], - "type": "array", + "description": "Folders to exclude from parsing", "items": {}, + "title": "Excl Paths", + "type": "array", "uniqueItems": true }, "autocomplete_no_prefix": { - "title": "Autocomplete No Prefix", - "description": "Do not filter autocomplete results by variable prefix", "default": false, + "description": "Do not filter autocomplete results by variable prefix", + "title": "Autocomplete No Prefix", "type": "boolean" }, "autocomplete_no_snippets": { - "title": "Autocomplete No Snippets", - "description": "Do not use snippets with place holders in autocomplete results", "default": false, + "description": "Do not use snippets with place holders in autocomplete results", + "title": "Autocomplete No Snippets", "type": "boolean" }, "autocomplete_name_only": { - "title": "Autocomplete Name Only", - "description": "Complete only the name of procedures and not the parameters", "default": false, + "description": "Complete only the name of procedures and not the parameters", + "title": "Autocomplete Name Only", "type": "boolean" }, "lowercase_intrinsics": { - "title": "Lowercase Intrinsics", - "description": "Use lowercase for intrinsics and keywords in autocomplete requests", "default": false, + "description": "Use lowercase for intrinsics and keywords in autocomplete requests", + "title": "Lowercase Intrinsics", "type": "boolean" }, "use_signature_help": { - "title": "Use Signature Help", - "description": "Use signature help instead of subroutine/function snippets. This effectively sets --autocomplete_no_snippets", "default": false, + "description": "Use signature help instead of subroutine/function snippets. This effectively sets --autocomplete_no_snippets", + "title": "Use Signature Help", "type": "boolean" }, "variable_hover": { - "title": "Variable Hover", - "description": "DEPRECATED: This option is always on. Show hover information for variables", "default": false, + "description": "DEPRECATED: This option is always on. Show hover information for variables", + "title": "Variable Hover", "type": "boolean" }, "hover_signature": { - "title": "Hover Signature", - "description": "Show signature information in hover for arguments ", "default": false, + "description": "Show signature information in hover for arguments ", + "title": "Hover Signature", "type": "boolean" }, "hover_language": { - "title": "Hover Language", - "description": "Language used for responses to hover requests a VSCode language id (default: fortran90)", "default": "fortran90", + "description": "Language used for responses to hover requests a VSCode language id (default: fortran90)", + "title": "Hover Language", "type": "string" }, "max_line_length": { - "title": "Max Line Length", - "description": "Maximum line length (default: -1)", "default": -1, + "description": "Maximum line length (default: -1)", + "title": "Max Line Length", "type": "integer" }, "max_comment_line_length": { - "title": "Max Comment Line Length", - "description": "Maximum comment line length (default: -1)", "default": -1, + "description": "Maximum comment line length (default: -1)", + "title": "Max Comment Line Length", "type": "integer" }, "disable_diagnostics": { - "title": "Disable Diagnostics", - "description": "Disable diagnostics", "default": false, + "description": "Disable diagnostics", + "title": "Disable Diagnostics", "type": "boolean" }, "pp_suffixes": { - "title": "Pp Suffixes", - "description": "File extensions to be parsed ONLY for preprocessor commands (default: all uppercase source file suffixes)", "default": [], - "type": "array", + "description": "File extensions to be parsed ONLY for preprocessor commands (default: all uppercase source file suffixes)", "items": {}, + "title": "Pp Suffixes", + "type": "array", "uniqueItems": true }, "include_dirs": { - "title": "Include Dirs", - "description": "Folders containing preprocessor files with extensions PP_SUFFIXES.", "default": [], - "type": "array", + "description": "Folders containing preprocessor files with extensions PP_SUFFIXES.", "items": {}, + "title": "Include Dirs", + "type": "array", "uniqueItems": true }, "pp_defs": { - "title": "Pp Defs", - "description": "A dictionary with additional preprocessor definitions. Preprocessor definitions are normally included via INCLUDE_DIRS", "default": {}, + "description": "A dictionary with additional preprocessor definitions. Preprocessor definitions are normally included via INCLUDE_DIRS", + "title": "Pp Defs", "type": "object" }, "symbol_skip_mem": { - "title": "Symbol Skip Mem", - "description": "Do not include type members in document symbol results", "default": false, + "description": "Do not include type members in document symbol results", + "title": "Symbol Skip Mem", "type": "boolean" }, "enable_code_actions": { - "title": "Enable Code Actions", - "description": "Enable experimental code actions (default: false)", "default": false, + "description": "Enable experimental code actions (default: false)", + "title": "Enable Code Actions", "type": "boolean" } - } + }, + "title": "fortls schema", + "type": "object" } diff --git a/fortls/schema.py b/fortls/schema.py index e9e7267a..bdfb260a 100644 --- a/fortls/schema.py +++ b/fortls/schema.py @@ -1,5 +1,6 @@ from __future__ import annotations +import json import pathlib from pydantic import Field, create_model @@ -23,13 +24,13 @@ def create_schema(root: pathlib.Path | None = None): continue val = arg.default desc: str = arg.help.replace("%(default)s", str(val)) # type: ignore - only_vals[arg.dest] = Field(val, description=desc) # type: ignore + only_vals[arg.dest] = (type(val), Field(val, description=desc)) # type: ignore m = create_model("fortls schema", **only_vals) m.__doc__ = "Schema for the fortls Fortran Language Server" with open(str(root / "fortls.schema.json"), "w", encoding="utf-8") as f: - print(m.schema_json(indent=2), file=f) + print(json.dumps(m.model_json_schema(), indent=2), file=f) print(f"Created schema file: {root / 'fortls.schema.json'}") diff --git a/setup.cfg b/setup.cfg index 93a97a3a..4190da1e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -62,7 +62,7 @@ dev = black isort pre-commit - pydantic==1.10.13 + pydantic docs = sphinx >= 4.0.0 sphinx-argparse