Repository: mathesar-foundation/mathesar

Issue:
Remove the lazydict dependency
## Problem
This project has a depencdency on lazydict (https://github.com/janrain/lazydict) which is no longer supported (latest version is 7 years ago)  and does not work with Python 3.10.

## Proposed solution
The lazydict is used only on one place in the code  https://github.com/centerofci/mathesar/blob/76f9d8517dd28d5255852b49f9ab864b5721fd8e/mathesar/api/display_options.py#L4
to avoid re-evaluating the `_money_display_options_schema`... There are a lot of ways that this can be resolved, for example instead of the lazydict we could use a normal dict and wrap `_money_display_options_schema` with `functools.cache` (https://docs.python.org/3/library/functools.html#functools.cache) to evaluate it only once.

## Additional context
I'd be happy to provide a PR for resolving this.



Discussion:
@spapas Please feel free to send a pull request for this issue.

Resolving patch:
diff --git a/mathesar/api/display_options.py b/mathesar/api/display_options.py
--- a/mathesar/api/display_options.py
+++ b/mathesar/api/display_options.py
@@ -1,6 +1,5 @@
 import json
 from mathesar.database.types import UIType
-from lazydict import LazyDictionary
 
 
 def _money_display_options_schema():
@@ -24,73 +23,70 @@ def _money_display_options_schema():
     }
 
 
-DISPLAY_OPTIONS_BY_UI_TYPE = LazyDictionary(
+DISPLAY_OPTIONS_BY_UI_TYPE = {
+    UIType.BOOLEAN:
     {
-        UIType.BOOLEAN:
-        {
-            "options": [
-                {
-                    "name": "input", "type": "string",
-                    "enum": ['dropdown', 'checkbox']
-                },
-                {
-                    'name': "custom_labels", "type": "object",
-                    "items": [
-                        {"name": "TRUE", "type": "string"},
-                        {'name': "FALSE", "type": "string"}
-                    ]
-                }
-            ]
+        "options": [
+            {
+                "name": "input", "type": "string",
+                "enum": ['dropdown', 'checkbox']
+            },
+            {
+                'name': "custom_labels", "type": "object",
+                "items": [
+                    {"name": "TRUE", "type": "string"},
+                    {'name': "FALSE", "type": "string"}
+                ]
+            }
+        ]
 
-        },
-        UIType.NUMBER:
-        {
-            "options": [
-                {
-                    "name": "show_as_percentage",
-                    "type": "string",
-                    "enum": ['dropdown', 'checkbox']
-                },
-                {
-                    "name": "use_grouping",
-                    "type": "string",
-                    "enum": ['true', 'false', 'auto']
-                },
-                {
-                    "name": "minimum_fraction_digits",
-                    "type": "number",
-                },
-                {
-                    "name": "maximum_fraction_digits",
-                    "type": "number",
-                },
-                {
-                    "name": "locale",
-                    "type": "string"
-                }
-            ]
-        },
-        UIType.DATETIME:
-        {
-            "options": [{"name": "format", "type": "string"}]
-        },
-        UIType.TIME:
-        {
-            "options": [{"name": "format", "type": "string"}]
-        },
-        UIType.DATE:
-        {
-            "options": [{"name": "format", "type": "string"}]
-        },
-        UIType.DURATION:
-        {
-            "options": [
-                {"name": "min", "type": "string"},
-                {"name": "max", "type": "string"},
-                {"name": "show_units", "type": "boolean"},
-            ]
-        },
-        # NOTE: below callable will be evaluated lazily by LazyDictionary
-        UIType.MONEY: _money_display_options_schema,
-    }
-)
+    },
+    UIType.NUMBER:
+    {
+        "options": [
+            {
+                "name": "show_as_percentage",
+                "type": "string",
+                "enum": ['dropdown', 'checkbox']
+            },
+            {
+                "name": "use_grouping",
+                "type": "string",
+                "enum": ['true', 'false', 'auto']
+            },
+            {
+                "name": "minimum_fraction_digits",
+                "type": "number",
+            },
+            {
+                "name": "maximum_fraction_digits",
+                "type": "number",
+            },
+            {
+                "name": "locale",
+                "type": "string"
+            }
+        ]
+    },
+    UIType.DATETIME:
+    {
+        "options": [{"name": "format", "type": "string"}]
+    },
+    UIType.TIME:
+    {
+        "options": [{"name": "format", "type": "string"}]
+    },
+    UIType.DATE:
+    {
+        "options": [{"name": "format", "type": "string"}]
+    },
+    UIType.DURATION:
+    {
+        "options": [
+            {"name": "min", "type": "string"},
+            {"name": "max", "type": "string"},
+            {"name": "show_units", "type": "boolean"},
+        ]
+    },
+    UIType.MONEY: _money_display_options_schema(),
+}


Test patch: