diff --git a/examples/simple.mojo b/examples/simple.mojo index 66a71d2..3f6855d 100644 --- a/examples/simple.mojo +++ b/examples/simple.mojo @@ -4,7 +4,7 @@ from dotenv import dotenv_values, load_dotenv from os import getenv -fn main() raises: +def main(): print("=" * 60) print("mojo-dotenv Example") print("=" * 60) diff --git a/pixi.toml b/pixi.toml index 07961cd..d5bf48c 100644 --- a/pixi.toml +++ b/pixi.toml @@ -1,4 +1,4 @@ -[project] +[workspace] authors = ["Michael Booth "] channels = ["conda-forge", "https://conda.modular.com/max"] name = "mojo-dotenv" diff --git a/src/dotenv/__init__.mojo b/src/dotenv/__init__.mojo index 6cac992..fe5a492 100644 --- a/src/dotenv/__init__.mojo +++ b/src/dotenv/__init__.mojo @@ -10,7 +10,7 @@ from .loader import load_dotenv from .finder import find_dotenv -fn dotenv_values(dotenv_path: String, verbose: Bool = False) raises -> Dict[String, String]: +def dotenv_values(dotenv_path: String, verbose: Bool = False) -> Dict[String, String]: """Parse a .env file and return its content as a dictionary. This function reads a .env file and returns a dictionary mapping diff --git a/src/dotenv/finder.mojo b/src/dotenv/finder.mojo index 5e70693..1ad9a4e 100644 --- a/src/dotenv/finder.mojo +++ b/src/dotenv/finder.mojo @@ -3,7 +3,7 @@ from pathlib import Path -fn find_dotenv(filename: String = ".env", raise_error_if_not_found: Bool = False, usecwd: Bool = False) raises -> String: +def find_dotenv(filename: String = ".env", raise_error_if_not_found: Bool = False, usecwd: Bool = False) -> String: """Search in increasingly higher folders for the given file. Searches upward from the current directory (or working directory if usecwd=True) diff --git a/src/dotenv/loader.mojo b/src/dotenv/loader.mojo index ed0f63c..0ba4613 100644 --- a/src/dotenv/loader.mojo +++ b/src/dotenv/loader.mojo @@ -5,7 +5,7 @@ from pathlib import Path from .parser import parse_dotenv -fn load_dotenv(dotenv_path: String, override: Bool = False, verbose: Bool = False) raises -> Bool: +def load_dotenv(dotenv_path: String, override: Bool = False, verbose: Bool = False) -> Bool: """Load variables from a .env file into the environment. Reads a .env file and sets all found variables as environment variables. diff --git a/src/dotenv/parser.mojo b/src/dotenv/parser.mojo index 5872934..9e6cb4f 100644 --- a/src/dotenv/parser.mojo +++ b/src/dotenv/parser.mojo @@ -7,7 +7,7 @@ from collections import Dict, Optional, List from os import getenv -fn to_chars(text: String) -> List[String]: +def to_chars(text: String) -> List[String]: """Convert a String into a list of single-codepoint Strings.""" var chars = List[String]() for slice in text.codepoint_slices(): @@ -15,7 +15,7 @@ fn to_chars(text: String) -> List[String]: return chars^ -fn join_chars(chars: List[String], start: Int, end: Int) -> String: +def join_chars(chars: List[String], start: Int, end: Int) -> String: """Join a slice of character list [start, end) into a String.""" var result = String("") var i = start @@ -25,7 +25,7 @@ fn join_chars(chars: List[String], start: Int, end: Int) -> String: return result -fn count_trailing_backslashes(text: String, end_pos: Int) -> Int: +def count_trailing_backslashes(text: String, end_pos: Int) -> Int: """Count consecutive backslashes before the given character position. Args: @@ -44,7 +44,7 @@ fn count_trailing_backslashes(text: String, end_pos: Int) -> Int: return count -fn lookup_variable(var_name: String, env_dict: Dict[String, String], fallback_literal: String) raises -> String: +def lookup_variable(var_name: String, env_dict: Dict[String, String], fallback_literal: String) -> String: """Look up a variable in env_dict, then system environment, else return literal. Args: @@ -65,7 +65,7 @@ fn lookup_variable(var_name: String, env_dict: Dict[String, String], fallback_li return fallback_literal -fn strip_inline_comment(line: String) -> String: +def strip_inline_comment(line: String) -> String: """Strip inline comments from a line. Handles # comments after values, but not within quotes. @@ -109,7 +109,7 @@ fn strip_inline_comment(line: String) -> String: return line -fn expand_variables(value: String, env_dict: Dict[String, String]) raises -> String: +def expand_variables(value: String, env_dict: Dict[String, String]) -> String: """Expand variable references in a value. Supports: @@ -182,7 +182,7 @@ fn expand_variables(value: String, env_dict: Dict[String, String]) raises -> Str return result -fn process_escapes(value: String) -> String: +def process_escapes(value: String) -> String: """Process escape sequences in a string. Handles: @@ -233,7 +233,7 @@ fn process_escapes(value: String) -> String: return result -fn strip_quotes(value: String) -> String: +def strip_quotes(value: String) -> String: """Strip outer quotes (single or double) from a value and process escapes. Args: @@ -261,7 +261,7 @@ fn strip_quotes(value: String) -> String: return v_str -fn parse_line(line: String, verbose: Bool = False) -> Optional[Tuple[String, String]]: +def parse_line(line: String, verbose: Bool = False) -> Optional[Tuple[String, String]]: """Parse a single line from a .env file. Handles: @@ -324,7 +324,7 @@ fn parse_line(line: String, verbose: Bool = False) -> Optional[Tuple[String, Str return (key, value) -fn parse_dotenv(content: String, verbose: Bool = False) raises -> Dict[String, String]: +def parse_dotenv(content: String, verbose: Bool = False) -> Dict[String, String]: """Parse the entire content of a .env file. Performs two passes: diff --git a/test_package.mojo b/test_package.mojo index 2aee751..dbe70c0 100644 --- a/test_package.mojo +++ b/test_package.mojo @@ -1,6 +1,6 @@ from dotenv import dotenv_values, load_dotenv, find_dotenv -fn main() raises: +def main(): # Basic smoke test: ensure we can import and call the public API without error. var path = find_dotenv() # We do not assert on specific values here; we just ensure calls succeed. diff --git a/tests/test_python_compat.mojo b/tests/test_python_compat.mojo index b36ad61..82f5eb6 100644 --- a/tests/test_python_compat.mojo +++ b/tests/test_python_compat.mojo @@ -5,7 +5,7 @@ from dotenv import dotenv_values from python import Python, PythonObject -fn test_fixture_against_python(fixture_path: String) raises: +def test_fixture_against_python(fixture_path: String): """Test a fixture matches python-dotenv results.""" var mojo_result = dotenv_values(fixture_path) var py = Python.import_module("dotenv")