From 47cbd93ab2c13cb5b739f2cc6f7bfab1d0ebf609 Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Wed, 25 Jun 2025 11:35:58 -0700 Subject: [PATCH 1/8] make tests pass and github actions --- .github/workflows/polyapi-tests.yml | 30 +++++++++++++++++++++++++++++ polyapi/deployables.py | 17 ++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/polyapi-tests.yml diff --git a/.github/workflows/polyapi-tests.yml b/.github/workflows/polyapi-tests.yml new file mode 100644 index 0000000..6cb9af6 --- /dev/null +++ b/.github/workflows/polyapi-tests.yml @@ -0,0 +1,30 @@ +name: Python Tests + +on: + pull_request: + branches: + - develop + - main + push: + branches: + - develop + - main + +jobs: + test: + name: Python Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + - name: Run tests + run: pytest tests/ \ No newline at end of file diff --git a/polyapi/deployables.py b/polyapi/deployables.py index d5c8bea..be3fc37 100644 --- a/polyapi/deployables.py +++ b/polyapi/deployables.py @@ -225,15 +225,24 @@ def print_docstring_function_comment(description: str, args: list, returns: dict arg_type = arg.get('type', '') desc = arg.get('description', '') if arg_type: - docstring += f' {name} ({arg_type}): {desc}\n' + docstring += f' {name} ({arg_type}):' + if desc: + docstring += f' {desc}' + docstring += '\n' else: - docstring += f' {name}: {desc}\n' + docstring += f' {name}:' + if desc: + docstring += f' {desc}' + docstring += '\n' return_type = returns.get('type', '') return_description = returns.get('description', '') if return_type: - docstring += f'\n Returns:\n {return_type}: {return_description}\n' - else: + docstring += f'\n Returns:\n {return_type}:' + if return_description: + docstring += f' {return_description}' + docstring += '\n' + elif return_description: docstring += f'\n Returns:\n {return_description}\n' docstring += ' """' From 5c2d9e9ecc3b0533c3e7e1e5561d5909efe1fcb8 Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Wed, 25 Jun 2025 13:34:35 -0700 Subject: [PATCH 2/8] comment + push --- polyapi/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/polyapi/__init__.py b/polyapi/__init__.py index 583d1f3..52d938a 100644 --- a/polyapi/__init__.py +++ b/polyapi/__init__.py @@ -10,11 +10,11 @@ __all__ = ["poly"] -if len(sys.argv) > 1 and sys.argv[1] not in CLI_COMMANDS: - currdir = os.path.dirname(os.path.abspath(__file__)) - if not os.path.isdir(os.path.join(currdir, "poly")): - print("No 'poly' found. Please run 'python3 -m polyapi generate' to generate the 'poly' library for your tenant.") - sys.exit(1) +# if len(sys.argv) > 1 and sys.argv[1] not in CLI_COMMANDS: +# currdir = os.path.dirname(os.path.abspath(__file__)) +# if not os.path.isdir(os.path.join(currdir, "poly")): +# print("No 'poly' found. Please run 'python3 -m polyapi generate' to generate the 'poly' library for your tenant.") +# sys.exit(1) class PolyCustomDict(TypedDict, total=False): From 4e6dbaa4997ad8684d7bff13bd449c9fd5d821b6 Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Wed, 25 Jun 2025 13:51:03 -0700 Subject: [PATCH 3/8] add dev_requirements --- .github/workflows/python-ci.yml | 7 +++++++ dev_requirements.txt | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 .github/workflows/python-ci.yml create mode 100644 dev_requirements.txt diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml new file mode 100644 index 0000000..1997108 --- /dev/null +++ b/.github/workflows/python-ci.yml @@ -0,0 +1,7 @@ + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r dev_requirements.txt + + - name: Run tests + run: pytest tests/ \ No newline at end of file diff --git a/dev_requirements.txt b/dev_requirements.txt new file mode 100644 index 0000000..8f81da5 --- /dev/null +++ b/dev_requirements.txt @@ -0,0 +1,3 @@ +-r requirements.txt +mock==5.2.0 +pytest \ No newline at end of file From 3e4283ea1d5e6c74e73c3d1e8565be5c9b455563 Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Wed, 25 Jun 2025 14:18:59 -0700 Subject: [PATCH 4/8] use dev requirements --- .github/workflows/polyapi-tests.yml | 30 ----------------------------- 1 file changed, 30 deletions(-) delete mode 100644 .github/workflows/polyapi-tests.yml diff --git a/.github/workflows/polyapi-tests.yml b/.github/workflows/polyapi-tests.yml deleted file mode 100644 index 6cb9af6..0000000 --- a/.github/workflows/polyapi-tests.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Python Tests - -on: - pull_request: - branches: - - develop - - main - push: - branches: - - develop - - main - -jobs: - test: - name: Python Tests - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pytest - - name: Run tests - run: pytest tests/ \ No newline at end of file From b8fb57de202c10bcb802944e80697f956e4351fa Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Wed, 25 Jun 2025 14:34:36 -0700 Subject: [PATCH 5/8] using mkdir to avoid poly not existing --- .github/workflows/python-ci.yml | 3 +++ polyapi/__init__.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 1997108..f8920c5 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -1,3 +1,6 @@ + - name: Create dummy poly directory for tests + run: mkdir -p polyapi/poly + - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/polyapi/__init__.py b/polyapi/__init__.py index 52d938a..583d1f3 100644 --- a/polyapi/__init__.py +++ b/polyapi/__init__.py @@ -10,11 +10,11 @@ __all__ = ["poly"] -# if len(sys.argv) > 1 and sys.argv[1] not in CLI_COMMANDS: -# currdir = os.path.dirname(os.path.abspath(__file__)) -# if not os.path.isdir(os.path.join(currdir, "poly")): -# print("No 'poly' found. Please run 'python3 -m polyapi generate' to generate the 'poly' library for your tenant.") -# sys.exit(1) +if len(sys.argv) > 1 and sys.argv[1] not in CLI_COMMANDS: + currdir = os.path.dirname(os.path.abspath(__file__)) + if not os.path.isdir(os.path.join(currdir, "poly")): + print("No 'poly' found. Please run 'python3 -m polyapi generate' to generate the 'poly' library for your tenant.") + sys.exit(1) class PolyCustomDict(TypedDict, total=False): From 9f9e51d5cc5d00091f7f2214e3a8c1edd71f7495 Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Thu, 26 Jun 2025 12:13:36 -0700 Subject: [PATCH 6/8] Revert deployables anf change whitespace for passing tests --- polyapi/deployables.py | 18 +++++------------- tests/test_deployables.py | 6 +++--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/polyapi/deployables.py b/polyapi/deployables.py index be3fc37..44e08bd 100644 --- a/polyapi/deployables.py +++ b/polyapi/deployables.py @@ -225,25 +225,17 @@ def print_docstring_function_comment(description: str, args: list, returns: dict arg_type = arg.get('type', '') desc = arg.get('description', '') if arg_type: - docstring += f' {name} ({arg_type}):' - if desc: - docstring += f' {desc}' - docstring += '\n' + docstring += f' {name} ({arg_type}): {desc}\n' else: - docstring += f' {name}:' - if desc: - docstring += f' {desc}' - docstring += '\n' + docstring += f' {name}: {desc}\n' return_type = returns.get('type', '') return_description = returns.get('description', '') if return_type: - docstring += f'\n Returns:\n {return_type}:' + docstring += f'\n Returns:\n {return_type}: {return_description}\n' + else: if return_description: - docstring += f' {return_description}' - docstring += '\n' - elif return_description: - docstring += f'\n Returns:\n {return_description}\n' + docstring += f'\n Returns:\n {return_description}\n' docstring += ' """' return docstring diff --git a/tests/test_deployables.py b/tests/test_deployables.py index 2339fd6..80ec742 100644 --- a/tests/test_deployables.py +++ b/tests/test_deployables.py @@ -66,11 +66,11 @@ def foobar(foo: str, bar: Dict[str, str]) -> int: """A function that does something really import. Args: - foo (str): - bar (Dict[str, str]): + foo (str): + bar (Dict[str, str]): Returns: - int: + int: """ print("Okay then!") return 7 From 8f04842109dd399272d4c342e97e2b7183f0dd48 Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:20:42 -0700 Subject: [PATCH 7/8] undo diff --- polyapi/deployables.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/polyapi/deployables.py b/polyapi/deployables.py index 44e08bd..be91055 100644 --- a/polyapi/deployables.py +++ b/polyapi/deployables.py @@ -233,9 +233,8 @@ def print_docstring_function_comment(description: str, args: list, returns: dict return_description = returns.get('description', '') if return_type: docstring += f'\n Returns:\n {return_type}: {return_description}\n' - else: - if return_description: - docstring += f'\n Returns:\n {return_description}\n' + elif return_description: + docstring += f'\n Returns:\n {return_description}\n' docstring += ' """' return docstring From 84865126300a228846d2b7a9308fe1b8ab8da2c2 Mon Sep 17 00:00:00 2001 From: Ashir Rao <69091220+Ash1R@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:23:49 -0700 Subject: [PATCH 8/8] undo deployables.py change --- polyapi/deployables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polyapi/deployables.py b/polyapi/deployables.py index be91055..d5c8bea 100644 --- a/polyapi/deployables.py +++ b/polyapi/deployables.py @@ -233,7 +233,7 @@ def print_docstring_function_comment(description: str, args: list, returns: dict return_description = returns.get('description', '') if return_type: docstring += f'\n Returns:\n {return_type}: {return_description}\n' - elif return_description: + else: docstring += f'\n Returns:\n {return_description}\n' docstring += ' """'