From 85334e90cd386f738a3f5f676b12e324a8a6921b Mon Sep 17 00:00:00 2001 From: r-spiewak <63987228+r-spiewak@users.noreply.github.com> Date: Thu, 19 Jun 2025 08:34:23 -0400 Subject: [PATCH 1/2] Rename obj config to settings --- src/python_template/__init__.py | 2 +- src/python_template/config/__init__.py | 2 +- src/python_template/config/load_config.py | 2 +- src/python_template/logger/logger.py | 4 ++-- src/python_template/utils/split_args_for_inits.py | 4 ++-- tests/test_config/test_load_config.py | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/python_template/__init__.py b/src/python_template/__init__.py index 41f22ed..8ed5595 100644 --- a/src/python_template/__init__.py +++ b/src/python_template/__init__.py @@ -1,3 +1,3 @@ """This is what the module exports.""" -from .config import config +from .config import settings diff --git a/src/python_template/config/__init__.py b/src/python_template/config/__init__.py index 54a97ac..e1ce144 100644 --- a/src/python_template/config/__init__.py +++ b/src/python_template/config/__init__.py @@ -1,3 +1,3 @@ """Expose Config class to module.""" -from .load_config import config +from .load_config import settings diff --git a/src/python_template/config/load_config.py b/src/python_template/config/load_config.py index 57368df..76e1ab2 100644 --- a/src/python_template/config/load_config.py +++ b/src/python_template/config/load_config.py @@ -29,4 +29,4 @@ class Config(BaseModel): config_dict = yaml.safe_load(f) # config = dict_to_namespace(config_dict) -config = Config(**config_dict) +settings = Config(**config_dict) diff --git a/src/python_template/logger/logger.py b/src/python_template/logger/logger.py index 7b6e465..88c24d3 100644 --- a/src/python_template/logger/logger.py +++ b/src/python_template/logger/logger.py @@ -9,9 +9,9 @@ from pathlib import Path from typing import cast -from python_template import config +from python_template.config import settings -DEBUG_PRINTS = config.debug_prints +DEBUG_PRINTS = settings.debug_prints class DebugCategory(IntEnum): diff --git a/src/python_template/utils/split_args_for_inits.py b/src/python_template/utils/split_args_for_inits.py index 8efe7da..54827ed 100644 --- a/src/python_template/utils/split_args_for_inits.py +++ b/src/python_template/utils/split_args_for_inits.py @@ -7,9 +7,9 @@ from collections import defaultdict from typing import Any, get_type_hints -from python_template import config +from python_template.config import settings -DEBUG_PRINTS = config.debug_prints +DEBUG_PRINTS = settings.debug_prints LEFTOVERS = "leftovers" diff --git a/tests/test_config/test_load_config.py b/tests/test_config/test_load_config.py index a67fba9..62ecd1b 100644 --- a/tests/test_config/test_load_config.py +++ b/tests/test_config/test_load_config.py @@ -4,7 +4,7 @@ import yaml -from python_template import config +from python_template import settings from python_template.config.load_config import Config, dict_to_namespace from python_template.constants import CONFIG_PATH @@ -42,5 +42,5 @@ def test_config_dict_to_namespace_recursive(): def test_loaded_config_is_class(): """Tests that load_config returns a namespace.""" - assert isinstance(config, Config) - assert hasattr(config, "debug_prints") + assert isinstance(settings, Config) + assert hasattr(settings, "debug_prints") From d72e52b2f10fdc5b7673773732c6235702e9cb8f Mon Sep 17 00:00:00 2001 From: r-spiewak <63987228+r-spiewak@users.noreply.github.com> Date: Thu, 19 Jun 2025 08:35:38 -0400 Subject: [PATCH 2/2] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31bf7f6..4d807c4 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,6 @@ Alternatively, set this template as an upstream branch and merge in changes acco 3. *Merge changes* (maybe do this on a branch other than main and make a PR into main): `git merge template/main -- allow-unrelated-histories` (for the main branch in the upstream template). 4. *Fix Merge Conflicts*: Fix the merge conflicts in your local branch. -However, both of these methods are messy, since the package name (`python_template`) changes, and (if the derived repo is created from the gitHub template) the merge will want to revert it back to `python_template` and put anything new into a `python_template` directory as well (since they don't have a shared history). +However, both of these methods are messy (at least the first time), since the package name (`python_template`) changes, and (if the derived repo is created from the gitHub template) the merge will want to revert it back to `python_template` and put anything new into a `python_template` directory as well (since they don't have a shared history). The possible way to avoid this is if the derived repo is created locally as a copy of this repo, since then they'll have a shared history (and then the flag `--allow-unrelated-histories` in step 3 can be omitted as well).