{"id":18994568,"url":"https://github.com/timelessnesses/typed_env","last_synced_at":"2025-04-22T12:49:15.207Z","repository":{"id":158645945,"uuid":"634137275","full_name":"timelessnesses/typed_env","owner":"timelessnesses","description":"A python module that help you have a type safety on enviroment variable","archived":false,"fork":false,"pushed_at":"2024-03-01T19:41:20.000Z","size":27,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T01:37:03.380Z","etag":null,"topics":["enviroment","environment-variables","python3","typing"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/timelessnesses-typed-env","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timelessnesses.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-29T06:53:16.000Z","updated_at":"2025-01-15T15:28:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"5d59894c-15b5-413c-8210-71426bc659bc","html_url":"https://github.com/timelessnesses/typed_env","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"634e9620c6e2a9b6f95a7c886659211125a0d09d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelessnesses%2Ftyped_env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelessnesses%2Ftyped_env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelessnesses%2Ftyped_env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelessnesses%2Ftyped_env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timelessnesses","download_url":"https://codeload.github.com/timelessnesses/typed_env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250243625,"owners_count":21398372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enviroment","environment-variables","python3","typing"],"created_at":"2024-11-08T17:26:03.469Z","updated_at":"2025-04-22T12:49:15.159Z","avatar_url":"https://github.com/timelessnesses.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typed-env\n\nA python module that help you have a type safety on enviroment variable (on runtime)\n\n## Documentation\n\n```python\ntimelessnesses.TypedEnv\n```\n\nA parent class that will help you ensure type safetiness on your enviroment variable.  \nUsage:\n\n```python\nfrom timelessnesses import typed_env\nimport datetime\n\nclass MyDotEnv(typed_env.TypedEnv):\n    # define your enviroment variable name and it's type (default value is optional and typing.Optional is also supported)\n    AMONG_US: bool = True\n    DISCORD_TOKEN: str\n    DATETIME: datetime.datetime = datetime.datetime.now()\n    NICE_DICTIONARY: typing.Dict[str, int] = {\"a\": 1, \"b\": 2}\n    DAMN_LIST: typing.List[int] = [1, 2, 3]\n    BALLS_KIND: BallsEnum # oh no! TypedEnv doesn't support my custom class!\n    # don't worry you can implement your own converter!\n\na = MyDotEnv()\na.add_validator(BallsEnum, lambda x: BallsEnum(int(x)))\na.get_env(typed_env.Method.dotenv, dotenv=\".env\") # you have options to either get only from dotenv or os.environ or both!\n\"\"\"\na.get_env(typed_env.Method.all, dotenv=\"path_to_.env\") # this fetch all the variable from both dotenv and os.environ\na.get_env(typed_env.Method.env) # this fetch all the variable from os.environ\na.get_env(typed_env.Method.dotenv, dotenv=\"path_to_.env\") # this fetch all the variable from dotenv\nNOTE: for dotenv/all method you have to supply dotenv argument\n\"\"\"\na.raise_error_on_unknown_env(False) # if this set to true any excessive enviroment variable will raise an error (default is True)\na.load() # let it do the work!\n```\n\n`TypedEnv` supports normal types like `str` or `int` and also `typing.Dict` and `typing.List` etc. But it also supports custom type by adding a validator, you are also allowed to overwrite the default validator by using `TypedEnv.add_validator` method.  \nCheck out more examples at `tests` folder!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimelessnesses%2Ftyped_env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimelessnesses%2Ftyped_env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimelessnesses%2Ftyped_env/lists"}