Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions .qlty/qlty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ test_patterns = [
"**/*.spec.*",
]

# ============================================================================
# Issue Triage - Rule-level Ignores
# ============================================================================
# Ignore Bandit B101 (assert_used) in test files - pytest uses assert statements
[[triage]]
match.plugins = ["bandit"]
match.rules = ["bandit:B101"]
match.file_patterns = [
"**/tests/**",
"**/test_*.py",
"**/*_test.py",
]
set.ignored = true

# Ignore Bandit B108 (hardcoded_tmp_directory) in test files - test fixtures use /tmp
[[triage]]
match.plugins = ["bandit"]
match.rules = ["bandit:B108"]
match.file_patterns = [
"**/tests/**",
"**/test_*.py",
"**/*_test.py",
]
set.ignored = true

Comment on lines +45 to +69
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Qlty qlty.toml triage schema [[triage]] match.plugins match.rules match.file_patterns set.ignored

💡 Result:

Short summary — meaning and usage of the qlty.toml triage keys you asked about:

  • [[triage]]: a rule block that matches issues and then overrides properties for matched issues (evaluated sequentially; first match wins). [1]
  • match.plugins: list of plugin names whose reported issues should be matched (e.g., ["eslint", "rubocop"]). [1]
  • match.rules: list of plugin-specific rule identifiers to match (e.g., ["eslint:react/prop-types"]). Wildcards are supported. [1]
  • match.file_patterns: list of glob patterns to limit matches to files (default "*" matches all files). [1]
  • set.ignored (boolean): when set to true the matched issues are ignored (suppressed at generation time and won’t appear in the web app). Use set.ignored = true under the [triage.set] block. [1][2]

Minimal example:

[[triage]]
[triage.match]
rules = ["eslint:react/prop-types"]
file_patterns = ["frontend/components/ui/**"]
[triage.set]
ignored = true

References:

  • Qlty project config / triage docs. [1]
  • Qlty CLI ignoring/triage examples (includes note that ignored issues are suppressed). [2]

🏁 Script executed:

# Search for pyproject.toml to check Bandit configuration
find . -name "pyproject.toml" -type f | head -5

Repository: ByronWilliamsCPA/python-libs

Length of output: 250


🏁 Script executed:

# Check full qlty.toml for context around Bandit configuration
fd "qlty.toml" -type f | head -5

Repository: ByronWilliamsCPA/python-libs

Length of output: 242


🏁 Script executed:

# Find and read .qlty/qlty.toml
find . -path "./.qlty/qlty.toml" -o -path "*/qlty.toml" | grep -E "\.qlty/qlty\.toml|qlty\.toml$" | head -1 | xargs -I {} sh -c 'wc -l {} && cat -n {}'

Repository: ByronWilliamsCPA/python-libs

Length of output: 7460


🏁 Script executed:

# Check pyproject.toml for Bandit configuration
cat -n ./pyproject.toml | grep -A 10 -B 2 -i "bandit\|exclude"

Repository: ByronWilliamsCPA/python-libs

Length of output: 4215


Triage configuration has two issues: incorrect TOML syntax and ineffective rules due to Bandit excluding tests.

The [[triage]] blocks use flat dot-notation keys (match.plugins, set.ignored) that don't match Qlty's documented schema, which requires nested [triage.match] and [triage.set] blocks. Additionally, these rules won't apply because Bandit is already configured in pyproject.toml to exclude the tests directory entirely (line 688: exclude_dirs = ["tests", ...]).

Corrected triage syntax
-# Ignore Bandit B101 (assert_used) in test files - pytest uses assert statements
-[[triage]]
-match.plugins = ["bandit"]
-match.rules = ["bandit:B101"]
-match.file_patterns = [
-    "**/tests/**",
-    "**/test_*.py",
-    "**/*_test.py",
-]
-set.ignored = true
-
-# Ignore Bandit B108 (hardcoded_tmp_directory) in test files - test fixtures use /tmp
-[[triage]]
-match.plugins = ["bandit"]
-match.rules = ["bandit:B108"]
-match.file_patterns = [
-    "**/tests/**",
-    "**/test_*.py",
-    "**/*_test.py",
-]
-set.ignored = true
+# Note: Bandit already excludes tests via exclude_dirs in pyproject.toml;
+# these triage rules are unnecessary. If test scanning is needed, remove
+# "tests" from tool.bandit.exclude_dirs in pyproject.toml and use:
+#
+# [[triage]]
+# [triage.match]
+# plugins = ["bandit"]
+# rules = ["bandit:B101", "bandit:B108"]
+# file_patterns = ["**/tests/**", "**/test_*.py", "**/*_test.py"]
+# [triage.set]
+# ignored = true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# ============================================================================
# Issue Triage - Rule-level Ignores
# ============================================================================
# Ignore Bandit B101 (assert_used) in test files - pytest uses assert statements
[[triage]]
match.plugins = ["bandit"]
match.rules = ["bandit:B101"]
match.file_patterns = [
"**/tests/**",
"**/test_*.py",
"**/*_test.py",
]
set.ignored = true
# Ignore Bandit B108 (hardcoded_tmp_directory) in test files - test fixtures use /tmp
[[triage]]
match.plugins = ["bandit"]
match.rules = ["bandit:B108"]
match.file_patterns = [
"**/tests/**",
"**/test_*.py",
"**/*_test.py",
]
set.ignored = true
# ============================================================================
# Issue Triage - Rule-level Ignores
# ============================================================================
# Note: Bandit already excludes tests via exclude_dirs in pyproject.toml;
# these triage rules are unnecessary. If test scanning is needed, remove
# "tests" from tool.bandit.exclude_dirs in pyproject.toml and use:
#
# [[triage]]
# [triage.match]
# plugins = ["bandit"]
# rules = ["bandit:B101", "bandit:B108"]
# file_patterns = ["**/tests/**", "**/test_*.py", "**/*_test.py"]
# [triage.set]
# ignored = true
🤖 Prompt for AI Agents
In @.qlty/qlty.toml around lines 45 - 69, The triage entries in .qlty/qlty.toml
use incorrect flat keys (e.g., match.plugins, set.ignored) and therefore won't
match Qlty's schema, and even if fixed they are ineffective because Bandit is
already configured to exclude the tests directory in pyproject.toml; update each
[[triage]] block to the nested schema (use [triage.match] with plugins and rules
arrays and [triage.match.file_patterns], and [triage.set] with ignored = true)
and then either remove these test-specific triage rules or remove/adjust the
Bandit exclude_dirs setting in pyproject.toml (whichever policy you want) so the
triage rules can actually apply.

# Default source for plugin definitions
[[source]]
name = "default"
Expand Down Expand Up @@ -72,17 +97,8 @@ default = true
[smells]
# Mode: comment (add PR comments) vs block (fail CI)
mode = "comment"

# Ignore complexity warnings for files with documented intentional complexity
[[smells.ignore]]
rules = [
"function-complexity",
"function-parameters",
"nested-control-flow",
]
file_patterns = [
"**/gemini_image/generator.py",
]
# Note: Complexity warnings for gemini_image/generator.py are intentional
# and documented in the file header. Use exclude_patterns at top level if needed.

Comment on lines 97 to 102
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Qlty configuration suppress smells complexity rules triage exclude_patterns

💡 Result:

Below is a concise recipe for configuring Qlty to exclude files, suppress/adjust smell (complexity) rules, and triage specific issues in .qlty/qlty.toml.

  1. Exclude files/paths
  • Top-level key: exclude_patterns (glob list). These files are not processed by any analysis.
  • Example:
    exclude_patterns = ["/node_modules/", "/generated/", "**/*.min.js"]. [1][3]
  1. Global smell / complexity settings
  • Top-level smells block controls overall behavior (mode) and thresholds (file_complexity, function_complexity).
  • Example:
    [smells]
    mode = "comment" # or "block", "monitor", "disabled"
    file_complexity = 50
    function_complexity = 15. [1]
  1. Per-language smell tuning
  • Use language..smells to override thresholds or duplication settings for a language.
  • Example:
    [language.rust.smells]
    function_complexity.threshold = 20
    duplication.nodes_threshold = 40. [1]
  1. Disable/ignore plugin checks on specific files
  • Use [[exclude]] blocks to stop plugins from running on matching files (evaluated sequentially; first match wins).
  • Example:
    [[exclude]]
    plugins = ["eslint"]
    file_patterns = ["frontend/components/ui/**"]. [1][2]
  1. Triaging (suppress or change issue properties)
  • Use [[triage]] entries with match and set sub-blocks. Can match by plugins, rules (plugin-specific names), levels, file_patterns. Use set.ignored = true to suppress.

  • Example:
    [[triage]]
    match.rules = ["eslint:react/prop-types"]
    match.file_patterns = ["frontend/components/ui/**"]
    set.ignored = true

    [[triage]]
    match.plugins = ["rubocop"]
    match.levels = ["low"]
    set.ignored = true. [1][2]

  1. Duplication settings
  • smells.duplication and language..smells.duplication support threshold and nodes_threshold to tune duplicate-code detection.
  • Example:
    [smells.duplication]
    threshold = 10
    nodes_threshold = 30. [1]

References

  • Qlty qlty.toml project config (exclude_patterns, smells, language, [[exclude]], [[triage]]). [1]
  • Qlty docs: Excluding files and triage/ignore examples. [2][3]

If you want, I can produce a ready-to-drop .qlty/qlty.toml example tailored to your repo (languages, complexity thresholds, and globs).


Use [[triage]] to suppress complexity warnings without excluding the entire file.

Line 101–102 suggests using exclude_patterns if needed; that excludes the file from all Qlty analysis. If the goal is only to silence complexity-related smells for gemini_image/generator.py, use a [[triage]] block instead:

[[triage]]
match.file_patterns = ["gemini_image/generator.py"]
match.plugins = ["smells"]
set.ignored = true

This suppresses smells for that file without removing it from other analyses.

🤖 Prompt for AI Agents
In @.qlty/qlty.toml around lines 97 - 102, Replace the blanket use of
exclude_patterns for gemini_image/generator.py by adding a [[triage]] block that
targets that file and the "smells" plugin: create a [[triage]] entry with
match.file_patterns set to ["gemini_image/generator.py"], match.plugins set to
["smells"], and set.ignored set to true so complexity warnings for that file are
suppressed without removing it from other Qlty analyses.

# Boolean logic complexity
[smells.boolean_logic]
Expand Down Expand Up @@ -145,15 +161,6 @@ drivers = ["lint"]
name = "bandit"
mode = "comment"

# Ignore B101 (assert_used) in test files - pytest uses assert statements
[[plugin.ignore]]
rule = "bandit:B101"
file_patterns = [
"**/tests/**",
"**/test_*.py",
"**/*_test.py",
]

# Shell script linting (comment mode - script styling preferences)
[[plugin]]
name = "shellcheck"
Expand Down
235 changes: 235 additions & 0 deletions FIXES_NEEDED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
# python-libs cloudflare-auth Package Fixes Needed

**Status**: Critical - Package cannot be used as a dependency
**Discovered**: 2025-12-06 during homelab-infra migration
**Reporter**: Claude Code (via ByronWilliams)

---

## Summary

The `byronwilliamscpa-cloudflare-auth` package has broken imports that prevent it from being used
as a dependency in other projects. This violates the core purpose of python-libs as a shared
library repository.

## Issues Found

### 1. ✅ FIXED LOCALLY: Incorrect Import Statements (21+ occurrences)

**Problem**: Module imports use `src.cloudflare_auth` instead of `cloudflare_auth`

**Status**: Fixed locally in this clone (not committed)

**Files Affected**:
- `packages/cloudflare-auth/src/cloudflare_auth/__init__.py`
- `packages/cloudflare-auth/src/cloudflare_auth/middleware.py`
- `packages/cloudflare-auth/src/cloudflare_auth/middleware_enhanced.py`
- `packages/cloudflare-auth/src/cloudflare_auth/validators.py`
- `packages/cloudflare-auth/src/cloudflare_auth/redis_sessions.py`
- And potentially others

**Example**:

```python
# Incorrect (current in repo)
from src.cloudflare_auth.models import CloudflareUser
from src.cloudflare_auth.middleware import CloudflareAuthMiddleware

# Correct (fixed locally)
from cloudflare_auth.models import CloudflareUser
from cloudflare_auth.middleware import CloudflareAuthMiddleware
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

**Fix Applied**:

```bash
cd packages/cloudflare-auth
find src -name "*.py" -exec sed -i 's/from src\.cloudflare_auth/from cloudflare_auth/g' {} \;
find src -name "*.py" -exec sed -i 's/import src\.cloudflare_auth/import cloudflare_auth/g' {} \;
```

---

### 2. ❌ NOT FIXED: Missing CloudflareSettings Module

**Problem**: Multiple files import from non-existent `src.config.settings` module

**Files Affected**:
- `packages/cloudflare-auth/src/cloudflare_auth/validators.py:40`
- `packages/cloudflare-auth/src/cloudflare_auth/middleware.py`
- `packages/cloudflare-auth/src/cloudflare_auth/middleware_enhanced.py`

**Import Statement**:

```python
from src.config.settings import CloudflareSettings, get_cloudflare_settings
```

**Problem**: This module doesn't exist in the cloudflare-auth package

**Options for Resolution**:

#### Option A: Create CloudflareSettings within package (RECOMMENDED)

```python
# packages/cloudflare-auth/src/cloudflare_auth/settings.py
from pydantic_settings import BaseSettings

class CloudflareSettings(BaseSettings):
"""Cloudflare Access configuration settings."""

cloudflare_team_domain: str
cloudflare_audience_tag: str
cloudflare_enabled: bool = True
service_token_enabled: bool = False
# ... other settings

class Config:
env_file = ".env"

def get_cloudflare_settings() -> CloudflareSettings:
"""Get singleton CloudflareSettings instance."""
return CloudflareSettings()
```

Then update imports:

```python
# In validators.py, middleware.py, middleware_enhanced.py
from cloudflare_auth.settings import CloudflareSettings, get_cloudflare_settings
```

#### Option B: Make settings injectable (alternative)

Remove direct settings import and require settings to be passed as parameters:

```python
# In validators.py
class CloudflareJWTValidator:
def __init__(self, team_domain: str, audience_tag: str):
self.team_domain = team_domain
self.audience_tag = audience_tag
```

**Recommendation**: Option A is preferred for backward compatibility and ease of use.

---

## Root Cause

The package appears to have been copied from a different project structure where it was nested under `src/` with a separate `src/config/` module. When moved to the python-libs monorepo structure, imports were not updated to reflect the new package structure.

---

## Impact

**Current State**:
- ❌ Package cannot be imported: `ModuleNotFoundError: No module named 'src.config'`
- ❌ Cannot be used as a dependency in other projects
- ❌ Forces code duplication instead of reuse
- ❌ Violates the stated purpose of python-libs repository

**Blocked Projects**:
- homelab-infra (PR #54) - waiting for these fixes before tests can run

---

## Action Items

### Immediate (Required for PR #54)

1. **Commit local import fixes**:

```bash
cd packages/cloudflare-auth
git add src/cloudflare_auth/*.py
git commit -m "fix: correct all module imports from src.cloudflare_auth to cloudflare_auth"
```

2. **Create CloudflareSettings module**:
- Create `src/cloudflare_auth/settings.py`
- Define `CloudflareSettings` and `get_cloudflare_settings`
- Update imports in affected files
- Test imports work correctly

3. **Add import tests**:

```python
# tests/test_imports.py
def test_public_imports():
"""Verify all public imports work correctly."""
from cloudflare_auth import (
CloudflareAuthMiddleware,
CloudflareUser,
setup_cloudflare_auth_enhanced,
)
assert CloudflareAuthMiddleware is not None
```

4. **Add CI check**:

```yaml
# .github/workflows/ci.yml
- name: Test package imports
run: |
uv run python -c "from cloudflare_auth import CloudflareUser"
```

### Follow-up (Before PyPI Publication)

5. **Publish to PyPI**:
- Once fixes are complete and tests pass
- Follow semantic versioning (v0.1.1 for patch)
- Update homelab-infra to use PyPI package instead of path dependency

6. **Update template**:
- Add import tests to cookiecutter-python-template
- Ensure packages in workspace members have validated imports

---
Comment on lines +139 to +189
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, check the repository structure
git ls-files | head -20

Repository: ByronWilliamsCPA/python-libs

Length of output: 766


🏁 Script executed:

# Verify the cloudflare-auth package directory structure
if [ -d "packages/cloudflare-auth" ]; then
  echo "✓ cloudflare-auth package exists"
  find packages/cloudflare-auth -type f -name "*.py" | head -20
else
  echo "✗ cloudflare-auth package not found"
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 1204


🏁 Script executed:

# Check for settings.py and examine FIXES_NEEDED.md
if [ -f "FIXES_NEEDED.md" ]; then
  echo "✓ FIXES_NEEDED.md exists"
  echo "Checking lines 139-189:"
  sed -n '139,189p' FIXES_NEEDED.md
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 1526


🏁 Script executed:

# Check if docs/secure.md exists and examine it
if [ -f "docs/secure.md" ]; then
  echo "✓ docs/secure.md exists"
  grep -n "CloudflareSettings" docs/secure.md | head -10
else
  echo "✗ docs/secure.md not found"
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 481


🏁 Script executed:

# Check the actual package structure
if [ -d "packages/cloudflare-auth/src/cloudflare_auth" ]; then
  echo "Contents of packages/cloudflare-auth/src/cloudflare_auth:"
  ls -la packages/cloudflare-auth/src/cloudflare_auth/
else
  echo "✗ Expected directory not found"
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 1194


🏁 Script executed:

# Check what's exported from __init__.py
echo "=== __init__.py contents ==="
cat -n packages/cloudflare-auth/src/cloudflare_auth/__init__.py

Repository: ByronWilliamsCPA/python-libs

Length of output: 3720


🏁 Script executed:

# Check if test_imports.py exists
if [ -f "packages/cloudflare-auth/tests/test_imports.py" ]; then
  echo "✓ test_imports.py exists"
  cat -n packages/cloudflare-auth/tests/test_imports.py
else
  echo "✗ test_imports.py does not exist (action item 3 proposes creating it)"
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 141


🏁 Script executed:

# Check settings.py to verify CloudflareSettings and get_cloudflare_settings are defined
echo "=== settings.py first 50 lines ==="
head -50 packages/cloudflare-auth/src/cloudflare_auth/settings.py

Repository: ByronWilliamsCPA/python-libs

Length of output: 1714


🏁 Script executed:

# Check existing CI workflows
if [ -d ".github/workflows" ]; then
  echo "=== CI Workflow files ==="
  ls -la .github/workflows/
else
  echo "✗ .github/workflows not found"
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 1379


🏁 Script executed:

# Check if the CI check already exists for imports
if [ -f ".github/workflows/ci.yml" ]; then
  echo "=== Checking for 'Test package imports' in ci.yml ==="
  grep -n "Test package imports" .github/workflows/ci.yml || echo "Not found"
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 135


🏁 Script executed:

# Check ci.yml to understand the current test structure and find where the import test should be added
cat -n .github/workflows/ci.yml | head -100

Repository: ByronWilliamsCPA/python-libs

Length of output: 3968


🏁 Script executed:

# Verify that CloudflareSettings and get_cloudflare_settings are actually exported and importable
grep -n "get_cloudflare_settings" packages/cloudflare-auth/src/cloudflare_auth/settings.py

Repository: ByronWilliamsCPA/python-libs

Length of output: 128


🏁 Script executed:

# Check if CloudflareSettings and get_cloudflare_settings are exported from __init__.py
grep "CloudflareSettings\|get_cloudflare_settings" packages/cloudflare-auth/src/cloudflare_auth/__init__.py

Repository: ByronWilliamsCPA/python-libs

Length of output: 54


🏁 Script executed:

# Verify test_settings.py already exists and what it covers
if [ -f "packages/cloudflare-auth/tests/test_settings.py" ]; then
  echo "✓ test_settings.py exists"
  wc -l packages/cloudflare-auth/tests/test_settings.py
  head -40 packages/cloudflare-auth/tests/test_settings.py
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 1422


🏁 Script executed:

# Check docs/secure.md to see what the intended migration path is for CloudflareSettings
echo "=== docs/secure.md sections about CloudflareSettings ==="
grep -B2 -A2 "CloudflareSettings" docs/secure.md | head -50

Repository: ByronWilliamsCPA/python-libs

Length of output: 859


🏁 Script executed:

# Check if settings should be in __all__ by looking at the full settings.py
tail -20 packages/cloudflare-auth/src/cloudflare_auth/settings.py

Repository: ByronWilliamsCPA/python-libs

Length of output: 705


🏁 Script executed:

# Verify the actual line count of FIXES_NEEDED.md to understand the context
wc -l FIXES_NEEDED.md

Repository: ByronWilliamsCPA/python-libs

Length of output: 91


🏁 Script executed:

# Check the markdown line length guideline compliance for FIXES_NEEDED.md around lines 139-189
sed -n '139,189p' FIXES_NEEDED.md | awk '{print length, $0}' | sort -rn | head -10

Repository: ByronWilliamsCPA/python-libs

Length of output: 723


🏁 Script executed:

# Check if the proposed test imports would actually work - verify CloudflareSettings is NOT exported
echo "=== Checking __all__ exports from __init__.py ==="
grep -A 50 "__all__" packages/cloudflare-auth/src/cloudflare_auth/__init__.py

Repository: ByronWilliamsCPA/python-libs

Length of output: 899


🏁 Script executed:

# Try to verify if importing the proposed items would work
python3 << 'EOF'
import sys
import os

# Simulate what the test would do
try:
    # This should work
    from cloudflare_auth import CloudflareUser
    print("✓ Can import CloudflareUser")
except ImportError as e:
    print(f"✗ Cannot import CloudflareUser: {e}")

try:
    # This should work
    from cloudflare_auth import CloudflareAuthMiddleware
    print("✓ Can import CloudflareAuthMiddleware")
except ImportError as e:
    print(f"✗ Cannot import CloudflareAuthMiddleware: {e}")

try:
    # This should work
    from cloudflare_auth import setup_cloudflare_auth_enhanced
    print("✓ Can import setup_cloudflare_auth_enhanced")
except ImportError as e:
    print(f"✗ Cannot import setup_cloudflare_auth_enhanced: {e}")

try:
    # This might NOT work - check if CloudflareSettings is exported
    from cloudflare_auth import CloudflareSettings
    print("✓ Can import CloudflareSettings from cloudflare_auth")
except ImportError as e:
    print(f"✗ Cannot import CloudflareSettings from cloudflare_auth: {e}")

try:
    # This will work
    from cloudflare_auth.settings import CloudflareSettings, get_cloudflare_settings
    print("✓ Can import CloudflareSettings from cloudflare_auth.settings")
except ImportError as e:
    print(f"✗ Cannot import from cloudflare_auth.settings: {e}")
EOF

Repository: ByronWilliamsCPA/python-libs

Length of output: 158


🏁 Script executed:

# Look more carefully at the CI section to see if there's any import testing
grep -n "import\|Import\|test.*import" .github/workflows/ci.yml

Repository: ByronWilliamsCPA/python-libs

Length of output: 54


🏁 Script executed:

# Check if there are any remaining "src.cloudflare_auth" imports that should be "cloudflare_auth"
grep -r "from src\.cloudflare_auth\|from src\.config" packages/cloudflare-auth/src/ 2>/dev/null | grep -v ".pyc" || echo "No src. imports found"

Repository: ByronWilliamsCPA/python-libs

Length of output: 93


🏁 Script executed:

# Check middleware.py and middleware_enhanced.py for import issues
head -30 packages/cloudflare-auth/src/cloudflare_auth/middleware.py | grep "^from\|^import"

Repository: ByronWilliamsCPA/python-libs

Length of output: 54


Action items 1–2 appear complete; items 3–4 (test_imports.py and CI check) remain pending.

The steps correctly reference the cloudflare-auth package structure and align with docs/secure.md. Import fixes appear done (no src.cloudflare_auth imports remain), and CloudflareSettings module exists in packages/cloudflare-auth/src/cloudflare_auth/settings.py.

However:

  • test_imports.py (item 3) does not yet exist; the proposed test is valid—all three imports are exported in __all__
  • CI check (item 4) is not present in .github/workflows/ci.yml; the proposed command is correct

All referenced file paths and import statements match the actual module layout. Sequencing is sound and ready to implement.

🤖 Prompt for AI Agents
In @FIXES_NEEDED.md around lines 139 - 189, Add the missing import test and CI
check: create tests/test_imports.py that imports CloudflareAuthMiddleware,
CloudflareUser, and setup_cloudflare_auth_enhanced from the cloudflare_auth
package and asserts the main symbol(s) are not None (to validate public
exports), and update .github/workflows/ci.yml to add a step (e.g., "Test package
imports") that runs a one-liner import command (python -c "from cloudflare_auth
import CloudflareUser") to catch import-time errors in CI.


## Files Changed Locally (Not Committed)

All files in `packages/cloudflare-auth/src/cloudflare_auth/`:
- `__init__.py` - Fixed imports and docstring
- `middleware.py` - Fixed imports
- `middleware_enhanced.py` - Fixed imports
- `validators.py` - Fixed imports
- `security_helpers.py` - Fixed imports
- `sessions.py` - Fixed imports
- `utils.py` - Fixed imports
- `whitelist.py` - Fixed imports
- `models.py` - Fixed imports
- `csrf.py` - Fixed imports
- `rate_limiter.py` - Fixed imports
- `redis_sessions.py` - Fixed imports

---

## Testing Verification

After fixes are applied, verify with:

```bash
# 1. Clean install test
cd /tmp
uv venv test-env
source test-env/bin/activate
uv pip install /path/to/python-libs/packages/cloudflare-auth

# 2. Import test
python -c "from cloudflare_auth import CloudflareUser, setup_cloudflare_auth_enhanced"

# 3. Run package tests
cd /path/to/python-libs/packages/cloudflare-auth
uv run pytest tests/ -v
```

---

## Contact

For questions or to coordinate fixes:
- **Project**: homelab-infra (blocked PR #54)
- **Reporter**: Claude Code
- **Related**: [homelab-infra PR #54](https://github.com/ByronWilliamsCPA/homelab-infra/pull/54)
1 change: 1 addition & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ path = [
"src/**",
"packages/**/src/**/*.py",
"packages/**/tests/**/*.py",
"packages/**/scripts/**/*.py",
"tools/**",
"tests/**",
"validation/**",
Expand Down
Loading
Loading