Skip to content

MPT-17674: propagate changes from template#212

Merged
svazquezco merged 1 commit intomainfrom
MPT-17674-propagate-changes-from-template
Feb 16, 2026
Merged

MPT-17674: propagate changes from template#212
svazquezco merged 1 commit intomainfrom
MPT-17674-propagate-changes-from-template

Conversation

@svazquezco
Copy link
Contributor

@svazquezco svazquezco commented Feb 16, 2026

Closes MPT-17674

  • Standardize environment variables: rename MPT_TOKEN → MPT_API_TOKEN and MPT_URL → MPT_API_BASE_URL across clients, tests, and error messages.
  • Env files: remove sensitive entries from .env.example and add .env.sample with example MPT_API_* and RP_* variables.
  • Makefile refactor: modularize Makefile into make/*.mk, add common targets (bash, build, check, check-all, down, format, run, test, uv-add, uv-add-dev, uv-upgrade), add repo e2e target and review target in external_tools.mk; add dynamic help, automatic PHONY discovery, and .DEFAULT_GOAL := help.
  • Make UX: introduce require helper and centralized bootstrap that includes make/*.mk.
  • Dockerfile updates: set WORKDIR to /mpt_api_client, rename VIRTUAL_ENV → UV_PROJECT_ENVIRONMENT, adjust COPY and uv sync behavior, add UV_CACHE_DIR, create appuser, chown runtime dirs, and run as appuser.
  • EditorConfig: add [{Makefile,*.mk}] section to use tab indentation for Makefiles.
  • CI/dev tooling: update .pre-commit-config.yaml (lowercase flake8 hooks) and add python-box==7.3.2 to mypy extras.
  • Documentation: replace Installation with Documentation/Getting started in README.md and add docs/PROJECT_DESCRIPTION.md with usage and development guidance.
  • Packaging: update pyproject.toml to use docs/PROJECT_DESCRIPTION.md as the package readme and include it in sdist.
  • Tests: update unit tests to use new env var names; no public API or function-signature changes.

@svazquezco svazquezco requested a review from a team as a code owner February 16, 2026 13:59
@svazquezco svazquezco changed the title MPT-17674: propagate-changes-from-template MPT-17674: propagate changes from template Feb 16, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Renames environment variables (MPT_TOKEN→MPT_API_TOKEN, MPT_URL→MPT_API_BASE_URL), adds sample env file, restructures Makefile into modular includes with new targets, updates Dockerfile (workdir, user isolation, UV changes), adjusts docs/README and pyproject, normalizes pre-commit deps, and updates tests to use new env vars.

Changes

Cohort / File(s) Summary
Editor & Env files
\.editorconfig, \.env.example, \.env.sample
Added EditorConfig section for Makefile,*.mk (tabs). Removed sample keys from .env.example; added example MPT_* and RP_* vars to .env.sample.
Pre-commit & Packaging
\.pre-commit-config\.yaml, pyproject\.toml
Normalized flake8 dependency casing and added python-box==7.3.2. Updated project README path and sdist include to docs/PROJECT_DESCRIPTION.md.
Docker
Dockerfile
Changed WORKDIR to /mpt_api_client, renamed VIRTUAL_ENV var to UV_PROJECT_ENVIRONMENT, adjusted COPY, modified uv sync flags, added dev/prod stage refinements (appuser, cache, chown), set runtime USER.
Documentation
README.md, docs/PROJECT_DESCRIPTION.md
Rewrote README into documentation-first layout with getting-started and Make guidance; added docs/PROJECT_DESCRIPTION.md with installation/usage/development docs.
Make system
Makefile, make/common.mk, make/external_tools.mk, make/repo.mk
Root Makefile now includes make/*.mk, sets default goal to help, and generates dynamic PHONY/help. make/common.mk introduces DC, RUN, RUN_IT and many targets (build, check, test, uv-*). make/external_tools.mk adds review. make/repo.mk adds e2e.
HTTP clients & tests
mpt_api_client/http/client.py, mpt_api_client/http/async_client.py, tests/unit/http/test_client.py, tests/unit/http/test_async_client.py, tests/unit/test_mpt_client.py
Renamed env vars used for configuration: MPT_TOKENMPT_API_TOKEN, MPT_URLMPT_API_BASE_URL. Updated error messages and tests to use new names; no public API signature changes.
Make snippets (grouped)
make/...
Added and modularized Make targets and help generation across included make/*.mk files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
Jira Issue Key In Title ✅ Passed The PR title contains exactly one Jira issue key in the format MPT-XXXX: MPT-17674.
Test Coverage Required ✅ Passed PR modifies 2 code files in mpt_api_client module and updates all 3 corresponding test files with environment variable name changes.
Single Commit Required ✅ Passed The PR contains exactly one commit (7c4a3cf feat: propagate-changes-from-template), meeting the requirement for a single commit to keep git history clean and easy to follow.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@svazquezco svazquezco force-pushed the MPT-17674-propagate-changes-from-template branch from 69ba216 to 5ea0669 Compare February 16, 2026 14:01
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Fix all issues with AI agents
In `@docs/PROJECT_DESCRIPTION.md`:
- Around line 1-46: The README header "mpt-tool CLI" is misleading given the
examples only show the Python clients; either rename the header to
"mpt-api-client" or add a short CLI usage section, and update the sync and async
code examples to explicitly mention and show the environment variable names
MPT_API_TOKEN and MPT_API_BASE_URL when instantiating MPTClient and
AsyncMPTClient (e.g., note they will be read from MPT_API_TOKEN /
MPT_API_BASE_URL), so readers know which env vars to set.

In `@mpt_api_client/http/async_client.py`:
- Around line 33-46: The async client currently only reads MPT_API_TOKEN and
MPT_API_BASE_URL, causing breakage for users who still use legacy env names;
update the initialization in async_client.py (the api_token and base_url
retrieval logic) to mirror the sync client’s compatibility shim: if
MPT_API_TOKEN or MPT_API_BASE_URL are missing, fall back to MPT_TOKEN and
MPT_URL respectively, emit a deprecation warning when the legacy variables
(MPT_TOKEN/MPT_URL) are used, and ensure the same error messages remain if
neither new nor legacy env vars nor explicit arguments are provided.

In `@mpt_api_client/http/client.py`:
- Around line 46-59: Add backward-compatible fallbacks for renamed env vars by
checking MPT_TOKEN when resolving api_token and MPT_URL when resolving base_url
before raising errors; update the api_token and base_url assignment logic in the
MPTClient initialization (the api_token and base_url variables shown) to prefer
the new env vars (MPT_API_TOKEN, MPT_API_BASE_URL) but fallback to MPT_TOKEN and
MPT_URL respectively if the new ones are missing, and emit a deprecation warning
(e.g., via warnings.warn or logger.warning) indicating the old env var is
deprecated and should be migrated.

In `@mpt_api_client/models/model.py`:
- Line 14: The class declaration “class MptBox(Box):  # type: ignore[misc]”
contains an unused type ignore; remove the trailing “# type: ignore[misc]” from
the MptBox declaration so the line reads simply “class MptBox(Box):” and rerun
type checks to confirm no real mypy/pyright error exists for Box or MptBox—if an
actual type error appears, instead document the specific error and add a
targeted ignore at the offending symbol (e.g., on the problematic attribute or
import) rather than ignoring the whole class declaration.
- Line 4: Replace the unused flake8 noqa on the private import in
mpt_api_client/models/model.py: change the import comment on _camel_killer to
use a mypy/type-checker suppression (type: ignore[attr-defined]) instead of `#
noqa: PLC2701` so the private attribute access is explicitly ignored by the type
checker; update the import line that references `_camel_killer` accordingly.
- Around line 28-44: The Box parent class is untyped, so add "type:
ignore[no-untyped-call]" comments to the super() calls to suppress mypy errors:
update the super().__setitem__(mapped_key, value) call in __setitem__, the
super().__setattr__(item, value) call in __setattr__, and the
super().__getattr__(item) call in __getattr__ to include the type ignore; keep
the existing _prep_key and _box_safe_attributes logic unchanged and ensure the
ignore comments are placed immediately on the lines invoking the parent methods
(__setitem__, __setattr__, __getattr__).

In `@pyproject.toml`:
- Line 7: The pyproject.toml currently sets readme =
"docs/PROJECT_DESCRIPTION.md" but the sdist include is limited to
"mpt_api_client", so the README may be omitted; update the sdist include
configuration to explicitly include the docs/PROJECT_DESCRIPTION.md (or the docs
directory) alongside "mpt_api_client" so the readme is packaged into sdists;
look for the packaging include/manifest settings in pyproject.toml (where
"mpt_api_client" is listed) and add "docs/PROJECT_DESCRIPTION.md" (or "docs/")
to that list.
🧹 Nitpick comments (2)
tests/unit/http/test_async_client.py (1)

59-70: Consider using raising=False for delenv to avoid KeyError.

If MPT_API_TOKEN or MPT_API_BASE_URL is not already set in the test environment, monkeypatch.delenv() will raise a KeyError by default. Using raising=False makes the tests more robust across different environments.

🔧 Proposed fix
 def test_async_http_without_token(monkeypatch):
-    monkeypatch.delenv("MPT_API_TOKEN")
+    monkeypatch.delenv("MPT_API_TOKEN", raising=False)

     with pytest.raises(ValueError):
         AsyncHTTPClient(base_url=API_URL)


 def test_async_http_without_url(monkeypatch):
-    monkeypatch.delenv("MPT_API_BASE_URL")
+    monkeypatch.delenv("MPT_API_BASE_URL", raising=False)

     with pytest.raises(ValueError):
         AsyncHTTPClient(api_token=API_TOKEN)
tests/unit/http/test_client.py (1)

49-60: Consider using raising=False for delenv to avoid KeyError.

Same as the async client tests - if these environment variables aren't set in the test environment, delenv will raise a KeyError.

🔧 Proposed fix
 def test_http_without_token(monkeypatch):
-    monkeypatch.delenv("MPT_API_TOKEN")
+    monkeypatch.delenv("MPT_API_TOKEN", raising=False)

     with pytest.raises(ValueError):
         HTTPClient(base_url=API_URL)


 def test_http_without_url(monkeypatch):
-    monkeypatch.delenv("MPT_API_BASE_URL")
+    monkeypatch.delenv("MPT_API_BASE_URL", raising=False)

     with pytest.raises(ValueError):
         HTTPClient(api_token=API_TOKEN)

@svazquezco svazquezco force-pushed the MPT-17674-propagate-changes-from-template branch from 5ea0669 to db15d3c Compare February 16, 2026 14:12
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 1-4: The SonarCloud badge URLs in the README reference the wrong
project key; update both occurrences of "softwareone-platform_mpt-tool" in the
two SonarCloud badge URLs to "softwareone-platform_mpt-api-python-client" so the
badges point to the configured SonarCloud project (update the two URLs shown in
the diff for the Quality Gate Status and Coverage badges).

In `@tests/unit/http/test_client.py`:
- Around line 49-51: The tests call monkeypatch.delenv("MPT_API_TOKEN") and
monkeypatch.delenv("MPT_API_BASE_URL") in test_http_without_token and
test_http_without_url which will raise KeyError if the env var is missing;
update those calls to use monkeypatch.delenv("MPT_API_TOKEN", raising=False) and
monkeypatch.delenv("MPT_API_BASE_URL", raising=False) so deletion is silent when
the variable is absent and the tests become robust.
🧹 Nitpick comments (6)
tests/unit/http/test_client.py (1)

56-58: Same consideration for MPT_API_BASE_URL deletion.

Apply the same raising=False pattern here:

 def test_http_without_url(monkeypatch):
-    monkeypatch.delenv("MPT_API_BASE_URL")
+    monkeypatch.delenv("MPT_API_BASE_URL", raising=False)
tests/unit/http/test_async_client.py (2)

59-61: Consider using raising=False for robustness.

Same as the sync client tests - if MPT_API_TOKEN isn't set in the environment, delenv will raise KeyError:

 def test_async_http_without_token(monkeypatch):
-    monkeypatch.delenv("MPT_API_TOKEN")
+    monkeypatch.delenv("MPT_API_TOKEN", raising=False)

66-68: Apply same raising=False pattern.

 def test_async_http_without_url(monkeypatch):
-    monkeypatch.delenv("MPT_API_BASE_URL")
+    monkeypatch.delenv("MPT_API_BASE_URL", raising=False)
README.md (1)

47-52: Consider using the actual repository URL or a clearer placeholder.

The <repository-url> placeholder may confuse users. Consider either using the actual GitHub URL or a more explicit placeholder like https://github.com/softwareone-platform/mpt-api-python-client.git.

📝 Suggested change
 ```bash
-git clone <repository-url>
+git clone https://github.com/softwareone-platform/mpt-api-python-client.git
</details>

</blockquote></details>
<details>
<summary>make/common.mk (2)</summary><blockquote>

`25-26`: **Minor: Extra space in conditional default value.**

The space before `tests/unit` in the `$(if ...)` else clause will include a leading space in the output when `args` is not provided. This is harmless but unintentional.


<details>
<summary>Suggested fix</summary>

```diff
 test:  ## Run test
-	$(RUN) pytest $(if $(args),$(args), tests/unit)
+	$(RUN) pytest $(if $(args),$(args),tests/unit)

28-36: Implicit dependency on require function.

The uv-add and uv-add-dev targets use $(call require,pkg) which is defined in the main makefile. This works because common.mk is included from there, but it creates an implicit coupling. Consider adding a comment at the top of this file noting that it must be included from the main makefile.

@svazquezco svazquezco force-pushed the MPT-17674-propagate-changes-from-template branch from db15d3c to 5fed003 Compare February 16, 2026 15:03
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@mpt_api_client/http/async_client.py`:
- Around line 33-46: Replace the long inline ValueError messages with dedicated
exception classes and raise those instead: add two custom exceptions (e.g.,
MissingAPITokenError and MissingBaseUrlError) defined near the top of
async_client.py (or in the same module) with their explanatory messages in the
class body or __str__, then update the MPTClient (or the initializer function
where api_token and base_url are validated) to raise MissingAPITokenError() when
api_token is missing and MissingBaseUrlError() when base_url is missing; this
satisfies Ruff TRY003 while keeping the validation logic in the existing symbols
(api_token, base_url, MPTClient) intact.

In `@mpt_api_client/http/client.py`:
- Around line 46-59: Replace the inline ValueError usages with dedicated
exception classes to satisfy TRY003: define two custom exceptions (e.g.,
MissingAPITokenError and MissingBaseURLError or a single MPTClientConfigError)
inheriting from ValueError and move the long messages into those exception
classes (either as class docstring or default message in __init__/__str__); then
update the code in mpt_api_client.http.client where api_token and base_url are
validated to raise the new exceptions instead of ValueError (references: the
api_token check and base_url check and any code that mentions MPTClient in the
error text).

@svazquezco svazquezco force-pushed the MPT-17674-propagate-changes-from-template branch from 5fed003 to 5b8327e Compare February 16, 2026 15:18
@svazquezco svazquezco force-pushed the MPT-17674-propagate-changes-from-template branch from 5b8327e to 7c4a3cf Compare February 16, 2026 15:32
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@Dockerfile`:
- Around line 16-20: In the Dockerfile update the RUN line that invokes the uv
sync command to remove the unsupported --dev flag (i.e., change the RUN invoking
"uv sync ... --dev" to omit --dev); this ensures uv sync runs with --frozen and
--no-cache only since dev deps are synced by default and the --dev flag causes
an error.
🧹 Nitpick comments (1)
Dockerfile (1)

10-14: Consider optimizing layer caching for faster builds.

Copying all source files before uv sync invalidates the dependency cache on every code change. Splitting this into two COPY steps allows Docker to reuse the cached dependency layer when only application code changes.

♻️ Proposed optimization for layer caching
 FROM base AS build
 
-COPY . .
+COPY pyproject.toml uv.lock ./
 
 RUN uv sync --frozen --no-cache --no-dev
+
+COPY . .

@svazquezco svazquezco force-pushed the MPT-17674-propagate-changes-from-template branch from 7c4a3cf to 7ce43b0 Compare February 16, 2026 17:08
@sonarqubecloud
Copy link

@svazquezco svazquezco merged commit 68c9e07 into main Feb 16, 2026
4 checks passed
@svazquezco svazquezco deleted the MPT-17674-propagate-changes-from-template branch February 16, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants