Skip to content

[chores] Removed old, deprecated code#1190

Merged
nemesifier merged 4 commits intoopenwisp:masterfrom
Viscous106:cleanup-deprecated-1-2-0
Jan 9, 2026
Merged

[chores] Removed old, deprecated code#1190
nemesifier merged 4 commits intoopenwisp:masterfrom
Viscous106:cleanup-deprecated-1-2-0

Conversation

@Viscous106
Copy link
Copy Markdown
Contributor

Supersedes #1182.

This PR removes the deprecated code marked for the 1.2.0 release.

Changes:

  • Removed deprecated code in config.py.
  • Fixed formatting issues (E303).
  • Updated setup.cfg to correct linting configuration for test settings.

Closes #1189

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 5, 2026

Walkthrough

This pull request removes four deprecated code elements scheduled for removal in version 1.2.0. The changes include: deletion of a wrapper function get_cached_checksum_args_rewrite() in the config base module, removal of backward-compatibility status handling for "running" values in the device report status view, elimination of a deprecated Celery task wrapper invalidate_device_checksum_view_cache(), and removal of a corresponding backward-compatibility test. All changes are deletions with no new functionality introduced.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description lacks required template sections like a checklist and clear reference to the existing issue within the template format. Follow the repository's PR description template more closely by including all checklist items and using the standard 'Closes #' format in the designated section.
Out of Scope Changes check ❓ Inconclusive The PR description mentions fixing E303 formatting issues and updating setup.cfg, which are not explicitly detailed in the raw summary and may be out of scope. Clarify whether formatting fixes and setup.cfg updates are necessary for this cleanup PR, or revert them to stay focused on removing deprecated code.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing deprecated code for the 1.2.0 release, which aligns with the changeset content.
Linked Issues check ✅ Passed The PR successfully addresses the primary objective of issue #1189 by removing deprecated code blocks in config.py and related deprecated functions across multiple files.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55806f5 and 8fd95ca.

📒 Files selected for processing (1)
  • openwisp_controller/config/controller/views.py
💤 Files with no reviewable changes (1)
  • openwisp_controller/config/controller/views.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0

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

Copy link
Copy Markdown
Contributor

@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 @openwisp_controller/config/controller/views.py:
- Around line 253-255: Add a clear "Breaking Changes" entry to CHANGES.rst for
version 1.2.0 stating that the agent status value "running" was removed from
config.STATUS (see allowed_status / required_params in controller.views) and
agents must now send "applied" instead of "running"; mention migration 0013
which updates DB records and explicitly warn deployed agents to update their
software to avoid validation failures.

In @setup.cfg:
- Around line 9-12: The exclude pattern currently set as "exclude =
./tests/*settings*.py" won’t match Flake8 paths (which are provided without
"./"); update the exclude entry to "exclude = tests/*settings*.py" so it
correctly excludes files like tests/openwisp2/settings.py, or alternatively
delete the exclude line and keep the existing per-file-ignores configuration if
you prefer relying solely on per-file-ignores.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6323bb and 31f4997.

📒 Files selected for processing (5)
  • openwisp_controller/config/base/config.py
  • openwisp_controller/config/controller/views.py
  • openwisp_controller/config/tasks.py
  • openwisp_controller/config/tests/test_controller.py
  • setup.cfg
💤 Files with no reviewable changes (3)
  • openwisp_controller/config/tests/test_controller.py
  • openwisp_controller/config/tasks.py
  • openwisp_controller/config/base/config.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
🔇 Additional comments (1)
openwisp_controller/config/controller/views.py (1)

260-281: LGTM! Status handling implementation is correct.

The removal of "running" status backward compatibility is clean. The implementation correctly:

  • Validates status values against the allowed set
  • Maintains the necessary "deactivating" → "deactivated" mapping for device lifecycle management
  • Dynamically dispatches to appropriate set_status_* methods
  • Handles error status with reason parameter

Note: The change is not documented in the Version 1.2.0 release notes. If this is a breaking change, it should be added to CHANGES.rst under a "Breaking Changes" section for Version 1.2.0 to inform users upgrading from earlier versions.

Comment thread openwisp_controller/config/controller/views.py
Comment thread setup.cfg Outdated
Comment on lines +9 to +12
exclude = ./tests/*settings*.py
max-line-length = 88
per-file-ignores =
tests/openwisp2/settings.py:F401,F403
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Jan 5, 2026

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

🏁 Script executed:

# Find and read setup.cfg
fd -t f "setup.cfg" -x cat {}

Repository: openwisp/openwisp-controller

Length of output: 366


🏁 Script executed:

# Check if the target settings file exists
fd -t f "settings.py" tests/

Repository: openwisp/openwisp-controller

Length of output: 99


🏁 Script executed:

# Test if the exclude pattern ./tests/*settings*.py would match tests/openwisp2/settings.py
python3 << 'EOF'
import fnmatch
import os

# Test pattern matching
pattern = "./tests/*settings*.py"
test_path = "tests/openwisp2/settings.py"
test_path_with_dot = "./tests/openwisp2/settings.py"

# fnmatch uses Unix shell-style wildcards
print(f"Pattern: {pattern}")
print(f"Test path: {test_path}")
print(f"Match (without ./): {fnmatch.fnmatch(test_path, pattern)}")
print(f"Match (with ./): {fnmatch.fnmatch(test_path_with_dot, pattern)}")

# Also check with the pattern without ./
pattern_no_dot = "tests/*settings*.py"
print(f"\nPattern without ./: {pattern_no_dot}")
print(f"Match: {fnmatch.fnmatch(test_path, pattern_no_dot)}")

# Check if pattern would match specific file
test_path2 = "tests/openwisp2/settings.py"
print(f"\nDoes './tests/*settings*.py' match '{test_path2}'?")
print(f"Result: {fnmatch.fnmatch(test_path2, pattern)}")
print(f"Result (with ./): {fnmatch.fnmatch('./' + test_path2, pattern)}")
EOF

Repository: openwisp/openwisp-controller

Length of output: 158


🏁 Script executed:

python3 << 'EOF'
import fnmatch

# Test pattern matching for flake8 exclude
pattern = "./tests/*settings*.py"
test_paths = [
    "tests/openwisp2/settings.py",
    "./tests/openwisp2/settings.py",
]

print("Pattern matching tests:")
for path in test_paths:
    match = fnmatch.fnmatch(path, pattern)
    print(f"  fnmatch('{path}', '{pattern}') = {match}")

# The key issue: does ./ in pattern require ./ in path?
print("\nPattern analysis:")
print(f"Pattern has ./ prefix: {pattern.startswith('./')}")
print(f"This means it expects paths starting with './'")
print(f"But exclude in flake8 typically gets paths without './' prefix")
EOF

Repository: openwisp/openwisp-controller

Length of output: 401


🌐 Web query:

flake8 exclude pattern ./ prefix behavior file path matching

💡 Result:

Short answer: Don't use a leading "./". Flake8 treats exclude entries as globs that it first tests against the base filename and then against the absolute path. A pattern starting with "./" is literal and generally won't match the absolute path Flake8 checks, so it will not reliably exclude the file. Use the directory/file path without the "./" (or use a glob like "*/subdir/file.py" or an absolute path) to get the expected exclusion. [1][2]

Sources:

  • Flake8 options: --exclude matches filename first, then absolute path; patterns are globs (examples include "lib/python" expanding via os.path.abspath()). [1]
  • Practical note / examples and behavior discussion on matching and how to target specific files (use project-relative paths or globs like "*/path/file.py"). [2]

References:
[1] flake8 documentation — Options (exclude/filename behavior).
[2] Stack Overflow — explanation of filename vs absolute-path matching and example patterns.


Fix the exclude pattern—it won't match the target file due to the ./ prefix.

The exclude pattern ./tests/*settings*.py is ineffective. Flake8 passes file paths without the leading ./ to the pattern matcher, so ./tests/*settings*.py won't match tests/openwisp2/settings.py. This is why per-file-ignores is needed as a workaround.

Either:

  1. Change exclude = ./tests/*settings*.py to exclude = tests/*settings*.py
  2. Or remove the exclude line entirely and rely solely on per-file-ignores for clarity
🤖 Prompt for AI Agents
In @setup.cfg around lines 9-12, The exclude pattern currently set as "exclude =
./tests/*settings*.py" won’t match Flake8 paths (which are provided without
"./"); update the exclude entry to "exclude = tests/*settings*.py" so it
correctly excludes files like tests/openwisp2/settings.py, or alternatively
delete the exclude line and keep the existing per-file-ignores configuration if
you prefer relying solely on per-file-ignores.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand why this is needed? I think we can safely remove it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the settings file exists and examine its content
fd -t f "settings.py" tests/ -x echo "File: {}" \; -x head -50 {}

Length of output: 1515


🏁 Script executed:

#!/bin/bash
# Run flake8 on the settings file to see what errors exist
cd tests/openwisp2 2>/dev/null && flake8 settings.py 2>&1 || echo "flake8 not available in sandbox"

# Alternative: check for import patterns that would trigger F401/F403
cat tests/openwisp2/settings.py 2>/dev/null | head -100

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check git history to see why this change was made
git log --oneline --all -p setup.cfg | grep -A5 -B5 "per-file-ignores" | head -30

Length of output: 322


🏁 Script executed:

#!/bin/bash
# Get the full content of the settings file to check for star imports and unused imports
cat tests/openwisp2/settings.py

Length of output: 10045


🏁 Script executed:

#!/bin/bash
# Search for star imports that would trigger F403
grep -n "import \*" tests/openwisp2/settings.py

# Search for patterns that commonly appear in test settings
grep -n "from.*import" tests/openwisp2/settings.py | tail -20

Length of output: 75


@nemesifier You're right that we can take a cleaner approach here.

The reason this was added is because tests/openwisp2/settings.py has a star import at line 294:

from .local_settings import *

This triggers F403 and F401 violations. However, the existing exclude pattern was already trying to handle this but doesn't work because of the ./ prefix issue that CodeRabbit flagged.

Instead of adding per-file-ignores, we should simply fix the existing exclude pattern by changing:

exclude = ./tests/*settings*.py

to:

exclude = tests/*settings*.py

That way the exclude pattern will work as originally intended, and we don't need the per-file-ignores addition at all. Would you prefer that approach?

@coveralls
Copy link
Copy Markdown

coveralls commented Jan 6, 2026

Coverage Status

coverage: 98.641% (+0.03%) from 98.612%
when pulling 74e376a on Viscous106:cleanup-deprecated-1-2-0
into d1569ab on openwisp:master.

@Viscous106 Viscous106 force-pushed the cleanup-deprecated-1-2-0 branch 2 times, most recently from 17cdf14 to 31f4997 Compare January 6, 2026 00:40
@Viscous106 Viscous106 force-pushed the cleanup-deprecated-1-2-0 branch from 31f4997 to 9314b1c Compare January 6, 2026 01:23
@Viscous106 Viscous106 marked this pull request as draft January 9, 2026 05:07
@Viscous106 Viscous106 marked this pull request as ready for review January 9, 2026 05:39
Copilot AI review requested due to automatic review settings January 9, 2026 05:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes deprecated code scheduled for removal in the 1.2.0 release, primarily backward compatibility features for the old "running" status value that was replaced by "applied" in earlier versions.

  • Removed deprecated task invalidate_device_checksum_view_cache from tasks.py
  • Removed deprecated function get_cached_checksum_args_rewrite from base/config.py
  • Removed test for deprecated "running" status backward compatibility
  • Updated flake8 configuration to add per-file-ignores for test settings

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
setup.cfg Added per-file-ignores configuration for F401/F403 in test settings
openwisp_controller/config/tests/test_controller.py Removed test for deprecated "running" status backward compatibility
openwisp_controller/config/tasks.py Removed deprecated invalidate_device_checksum_view_cache task
openwisp_controller/config/controller/views.py Attempted to remove backward compatibility code for "running" status, but incomplete
openwisp_controller/config/base/config.py Removed deprecated get_cached_checksum_args_rewrite function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openwisp_controller/config/controller/views.py Outdated
Comment thread openwisp_controller/config/controller/views.py Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

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

Looks good, I have one comment below @Viscous106.

Comment thread setup.cfg Outdated
Comment on lines +9 to +12
exclude = ./tests/*settings*.py
max-line-length = 88
per-file-ignores =
tests/openwisp2/settings.py:F401,F403
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand why this is needed? I think we can safely remove it.

@Viscous106
Copy link
Copy Markdown
Contributor Author

Looks good, I have one comment below @Viscous106.

I added this because my local linter was flagging F401/F403 errors in that file. However, I agree it's better to keep the config clean if it's not strictly necessary for the CI . I will remove it and push the update. Thanks!

@Viscous106 Viscous106 force-pushed the cleanup-deprecated-1-2-0 branch from 55806f5 to 8fd95ca Compare January 9, 2026 13:27
@nemesifier
Copy link
Copy Markdown
Member

Thanks!

@nemesifier nemesifier merged commit c033a07 into openwisp:master Jan 9, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in OpenWISP Contributor's Board Jan 9, 2026
@nemesifier nemesifier changed the title [fix] Remove deprecated code for 1.2.0 release [chores] Removed old, deprecated code Jan 9, 2026
@Viscous106 Viscous106 deleted the cleanup-deprecated-1-2-0 branch January 9, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

[cleanup] Remove deprecated code for 1.2.0 release

4 participants