From 24e9ee3e23db1481b83968e1954fd0e447d03c46 Mon Sep 17 00:00:00 2001 From: nvphungdev <283886185+nvphungdev@users.noreply.github.com> Date: Sun, 17 May 2026 09:01:31 +0700 Subject: [PATCH] feat: load modular one methods Signed-off-by: nvphungdev <283886185+nvphungdev@users.noreply.github.com> --- .github/workflows/verify.yml | 2 + README.md | 2 +- docs/METHODS.md | 2 +- is_one_one.py | 125 +++++++++++++++++++++-------------- methods/__init__.py | 0 methods/sample_method.py | 11 +++ test_core.py | 26 ++++++-- 7 files changed, 114 insertions(+), 54 deletions(-) create mode 100644 methods/__init__.py create mode 100644 methods/sample_method.py diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 3cd3519..83ea9a4 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -41,6 +41,7 @@ jobs: if: success() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') uses: thollander/actions-comment-pull-request@v2 with: + comment_tag: logic-verification-ci message: | ### ✅ Logic Verified! The **Automated Logic Suite** has confirmed that 1 is still 1. @@ -54,6 +55,7 @@ jobs: if: failure() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') uses: thollander/actions-comment-pull-request@v2 with: + comment_tag: logic-verification-ci message: "### ❌ LOGIC COLLAPSE\nThe automated suite has detected that 1 is no longer 1. Please fix the broken logic before merging." github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index d4cf677..792615b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Wanna make this dumber? You're welcome here. All you have to do is: 1. **Fork** this repo. -2. Add a new function to `is_one_one.py`. +2. Add a new `is_one...` function in a Python file under `methods/`. 3. Make sure it returns `True` (because 1 is 1). 4. **Important:** If your code is easy to understand, you're doing it wrong. We want chaos, not clean code. 5. Bonus points for using libraries that have no business being in a math script (like `BeautifulSoup` or `Pandas`). diff --git a/docs/METHODS.md b/docs/METHODS.md index d5c1223..ed71572 100644 --- a/docs/METHODS.md +++ b/docs/METHODS.md @@ -1,6 +1,6 @@ # Methods Directory -This document provides a comprehensive list of all the functions available in `is_one_one.py` used to prove that 1 is indeed 1. +This document provides a comprehensive list of all the functions available through `is_one_one.py` used to prove that 1 is indeed 1. Community methods can live in `methods/*.py`; any function whose name starts with `is_one` is loaded automatically. ## Available Methods diff --git a/is_one_one.py b/is_one_one.py index 9c4396a..edd3b54 100644 --- a/is_one_one.py +++ b/is_one_one.py @@ -1,10 +1,57 @@ -import math -import sys +import importlib +import inspect +import pkgutil +from pathlib import Path + +METHOD_FUNCTION_PREFIX = "is_one" +METHODS_DIRECTORY = Path(__file__).resolve().with_name("methods") +EXTRA_CHECK_FUNCTION_NAMES = {"the_one_suriya"} + + +def load_method_functions(): + """Dynamically loads all validation functions from the methods package.""" + loaded_methods = {} + + if not METHODS_DIRECTORY.exists(): + return loaded_methods + + for module_info in pkgutil.iter_modules([str(METHODS_DIRECTORY)]): + if module_info.name.startswith("_"): + continue + + module = importlib.import_module(f"methods.{module_info.name}") + + for name, value in inspect.getmembers(module, inspect.isfunction): + if not name.startswith(METHOD_FUNCTION_PREFIX): + continue + if value.__module__ != module.__name__: + continue + loaded_methods[name] = value + + return loaded_methods + + +globals().update(load_method_functions()) + + +def get_available_checks(include_meta_check=False): + """Collects every available one-verification function.""" + checks = [] + for name, value in sorted(globals().items()): + if not name.startswith(METHOD_FUNCTION_PREFIX) and name not in EXTRA_CHECK_FUNCTION_NAMES: + continue + if name == "is_one_just_to_be_sure" and not include_meta_check: + continue + if callable(value): + checks.append(value) + return checks + def is_one(): """Validates one through direct equality.""" return 1 == 1 + def is_number_one(value: int) -> bool: """The one function that actually takes an argument. @@ -13,34 +60,37 @@ def is_number_one(value: int) -> bool: """ return value == 1 + def is_one_unicode_distance(): """Calculates one from adjacent Unicode code points.""" return ord("b") - ord("a") == 1 + def is_one_using_time_travel(): """Verifies one through time-derived arithmetic.""" import datetime import math - + now = datetime.datetime.now() useless = math.factorial(1) + math.sin(0) + len(str(now.year)) - + if useless > 0: return True else: return True + def is_one_using_interdimensional_tax_fraud(): """Validates one through deterministic cosmic arithmetic.""" - import math import datetime + import math import random import uuid cosmic_alignment = math.sqrt(1) * math.exp(0) - + government_surveillance_id = uuid.uuid4() - + current_year_vibrations = sum( [int(x) for x in str(datetime.datetime.now().year)] ) @@ -54,9 +104,6 @@ def is_one_using_interdimensional_tax_fraud(): return abs(math.cos(0)) == 1 -def is_one_using_binary(): - """Parses a binary string to validate one.""" - return int("1", 2) == 1 def is_one_under_extreme_pressure(): """Verifies one after nested dictionary traversal.""" @@ -67,58 +114,41 @@ def is_one_under_extreme_pressure(): current = vault while "layer" in current: current = current["layer"] - + return current["val"] == 1 + def is_one_using_roman_numerals(): """Calculates one from a Roman numeral token.""" - roman="I" - roman_values={"I":1,"V":5,"X":10} - total=0 + roman = "I" + roman_values = {"I": 1, "V": 5, "X": 10} + total = 0 for char in roman: - total+= roman_values[char] + total += roman_values[char] return total == 1 + def the_one_suriya(): - greatest_actor="suriya" - the_legend="suriya" - the_handsome="suriya" - great_man="suriya" - humble_man="suriya" - suriya=1 + greatest_actor = "suriya" + the_legend = "suriya" + the_handsome = "suriya" + great_man = "suriya" + humble_man = "suriya" + suriya = 1 return suriya + def is_one_just_to_be_sure(): """Verifies one by aggregating every proof.""" - return all([ - is_one(), - is_one_unicode_distance(), - is_one_using_time_travel(), - is_one_using_interdimensional_tax_fraud(), - is_one_using_binary(), - is_one_using_interdimensional_tax_fraud(), - is_one_using_roman_numerals(), - is_one_under_extreme_pressure(), - the_one_suriya(), - ]) + return all(func() for func in get_available_checks()) + def main(): """Runs all available one verification functions.""" - checks = [ - is_one, - is_one_unicode_distance, - is_one_just_to_be_sure, - is_one_using_time_travel, - is_one_using_interdimensional_tax_fraud, - is_one_using_binary, - is_one_using_roman_numerals, - is_one_using_interdimensional_tax_fraud, - is_one_under_extreme_pressure, - the_one_suriya, - ] - + checks = get_available_checks(include_meta_check=True) + print("🧠 Running overengineered checks to see if 1 == 1:\n") - + for i, func in enumerate(checks, 1): try: result = func() @@ -129,7 +159,6 @@ def main(): print("\nConclusion: 1 is indeed 1. My work here is done.") + if __name__ == "__main__": main() - - diff --git a/methods/__init__.py b/methods/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/methods/sample_method.py b/methods/sample_method.py new file mode 100644 index 0000000..412cf46 --- /dev/null +++ b/methods/sample_method.py @@ -0,0 +1,11 @@ +"""Sample methods loaded dynamically by is_one_one.py.""" + + +def is_one_unicode_distance(): + """Calculates one from adjacent Unicode code points.""" + return ord("b") - ord("a") == 1 + + +def is_one_using_binary(): + """Parses a binary string to validate one.""" + return int("1", 2) == 1 diff --git a/test_core.py b/test_core.py index a1ded15..744a934 100644 --- a/test_core.py +++ b/test_core.py @@ -1,6 +1,7 @@ -"""Test suite for is_one_one — now with proper unittest structure.""" +"""Test suite for is_one_one -- now with proper unittest structure.""" import unittest + import is_one_one import sys import io @@ -51,14 +52,14 @@ def test_is_one_just_to_be_sure(self): class TestIsNumberOne(unittest.TestCase): - """Negative testing — verify is_number_one rejects non-one values.""" + """Negative testing -- verify is_number_one rejects non-one values.""" def test_one_is_one(self): """1 should be recognized as 1.""" self.assertTrue(is_one_one.is_number_one(1)) def test_two_is_not_one(self): - """2 is not 1 — the first function in this repo that can return False.""" + """2 is not 1 -- the first function in this repo that can return False.""" self.assertFalse(is_one_one.is_number_one(2)) def test_zero_is_not_one(self): @@ -66,7 +67,7 @@ def test_zero_is_not_one(self): self.assertFalse(is_one_one.is_number_one(0)) def test_negative_one_is_not_one(self): - """-1 is not 1 (even though it contains '1').""" + """-1 is not 1, even though it contains '1'.""" self.assertFalse(is_one_one.is_number_one(-1)) def test_large_number_is_not_one(self): @@ -74,5 +75,22 @@ def test_large_number_is_not_one(self): self.assertFalse(is_one_one.is_number_one(9999)) +class TestDynamicMethodLoader(unittest.TestCase): + """Verify methods can be loaded from the methods package.""" + + def test_dynamic_method_loader_loads_sample_methods(self): + self.assertEqual(is_one_one.is_one_using_binary.__module__, "methods.sample_method") + self.assertTrue(is_one_one.is_one_using_binary()) + + def test_available_checks_include_dynamic_methods(self): + check_names = { + func.__name__ + for func in is_one_one.get_available_checks(include_meta_check=True) + } + + self.assertIn("is_one_using_binary", check_names) + self.assertIn("is_one_unicode_distance", check_names) + + if __name__ == "__main__": unittest.main()