Skip to content

Commit

Permalink
remove case sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Mar 15, 2024
1 parent 01e71d7 commit 0947b67
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ repos:
hooks:
- id: isort

default_language_version:
python: python3.11
10 changes: 3 additions & 7 deletions ragdoll/base.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import abc
from typing import Any, Mapping, Optional, Type, Union

from ragdoll import errors, utils
from ragdoll import errors


class BaseEntry(abc.ABC):

_NOT_SET = object()
DEFAULT_EXPORT = False
source: dict
source: Mapping

def __init__(
self,
Expand Down Expand Up @@ -89,11 +89,7 @@ def __init__(cls: Type["BaseSetting"], *args, **kwargs):
class BaseSetting(metaclass=SettingMeta):

auto_configure = True

@abc.abstractmethod
@utils.classproperty
def source(cls) -> Mapping: # pragma: no cover
raise NotImplementedError
source: Mapping

@classmethod
def configure_entry(cls, entry: BaseEntry, name: str, value: str):
Expand Down
17 changes: 2 additions & 15 deletions ragdoll/env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import typing

from ragdoll import errors, utils
from ragdoll import errors
from ragdoll.base import BaseEntry, BaseSetting

__all__ = ["EnvSetting", "BaseEnvEntry", "StrEnv", "BoolEnv", "IntEnv"]
Expand All @@ -13,8 +13,6 @@ def get_raw_value(self) -> str:

def __set_name__(self, owner: typing.Type["EnvSetting"], name: str):
super().__set_name__(owner, name)
if not owner.case_sensitive:
self._name = name.lower()


class StrEnv(BaseEnvEntry):
Expand Down Expand Up @@ -68,15 +66,4 @@ def __get__(self, *args, **kwargs) -> bool: ...


class EnvSetting(BaseSetting):
case_sensitive = True
_source: typing.Optional[typing.Mapping] = None

@utils.classproperty
def source(cls) -> typing.Mapping:
if not cls._source:
if cls.case_sensitive:
cls._source = os.environ
else:
cls._source = {k.lower(): v for k, v in os.environ.items()}

return cls._source
source = os.environ

0 comments on commit 0947b67

Please sign in to comment.