Skip to content

Conversation

pfouque
Copy link
Member

@pfouque pfouque commented Jun 25, 2025

Fixes #55

Add a new argument to ignore specific transitions from graph

app = apps.get_app(field_spec[0])
models = apps.get_models(app)
for model in models:
app = apps.get_app_config(field_spec[0])
Copy link
Member Author

Choose a reason for hiding this comment

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

apps.get_app was renamed decades ago 😅

@pfouque pfouque force-pushed the graph_transition_command_ignore branch from 613432b to d553b35 Compare June 25, 2025 15:29
@pfouque pfouque requested a review from Copilot June 25, 2025 15:30
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
...jango_fsm/management/commands/graph_transitions.py 89.47% <100.00%> (+5.07%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@Copilot 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

Adds a new --exclude (-e) option to the graph_transitions management command so users can omit named transitions from the generated graph.

  • Introduce --exclude flag in argument parser and propagate it to generate_dot
  • Update generate_dot to skip transitions listed in exclude
  • Refactor tests to loop over models and add a test_exclude, plus document the flag in README

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/testapp/tests/test_graph_transitions.py Refactored existing tests to iterate over multiple models and added test_exclude
django_fsm/management/commands/graph_transitions.py Added --exclude argument, updated generate_dot signature and handler call
README.md Added example usage for the -e flag to exclude transitions
Comments suppressed due to low confidence (2)

django_fsm/management/commands/graph_transitions.py:144

  • The help text for the --exclude flag could be clearer by indicating that multiple transition names should be comma-separated and that whitespace will be trimmed. For example: help="Comma-separated list of transition names to ignore (whitespace will be trimmed)."
        parser.add_argument(

tests/testapp/tests/test_graph_transitions.py:26

  • The test_exclude test currently only invokes the command without verifying its effect. Consider capturing the command output and asserting that the specified transitions are indeed omitted from the generated graph data.
            call_command("graph_transitions", "-e", "standard,no_target", model)

fields_data += all_fsm_fields_data(model)
dotdata = generate_dot(fields_data)

dotdata = generate_dot(fields_data, ignore_transitions=options["exclude"].split(","))
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

Parsing the exclude option with raw split may include empty strings and leading/trailing whitespace, causing mismatches. Consider using options['exclude'].split(',') if options['exclude'] else [] and stripping each entry (e.g., [name.strip() for name in ... if name.strip()]) before passing to generate_dot.

Suggested change
dotdata = generate_dot(fields_data, ignore_transitions=options["exclude"].split(","))
exclude_transitions = [name.strip() for name in options["exclude"].split(",") if name.strip()] if options["exclude"] else []
dotdata = generate_dot(fields_data, ignore_transitions=exclude_transitions)

Copilot uses AI. Check for mistakes.

@pfouque pfouque force-pushed the graph_transition_command_ignore branch from d553b35 to 78e1b61 Compare June 25, 2025 15:43
@pfouque pfouque merged commit 4bd42ac into main Jun 25, 2025
9 checks passed
@pfouque pfouque deleted the graph_transition_command_ignore branch June 25, 2025 16:08
pfouque added a commit that referenced this pull request Jun 25, 2025
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.

graph_transitions Command: Make it possible to ignore some transitions
1 participant