Skip to content

Remove dead pre-2021 HOST_APP version checks - #3559

Merged
jmcouffin merged 8 commits into
developfrom
cursor/remove-dead-host-version-checks-2580
Aug 25, 2026
Merged

jmcouffin merged 8 commits into
developfrom
cursor/remove-dead-host-version-checks-2580

Conversation

@jmcouffin

@jmcouffin jmcouffin commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #3438 (drop Revit 2013–2020): unwrap Python host-version gates that are now always true or always false.

HOST_APP.is_newer_than(v) is host > v. With a minimum host of 2021, checks against 2013–2020 (and is_newer_than(2021, or_equal=True)) no longer branch. This PR keeps the remaining supported-API path and deletes the unused MatchConfigWindowLegacy UI.

Description

Removes dead HOST_APP.is_newer_than / is_older_than / equivalent HOST_APP.version comparisons in pyrevitlib and bundled extensions. Live gates for 2022+, 2024+, and 2026+ are unchanged.

is_newer_than(2021) without or_equal is still live (false on 2021, true on 2022+). Those call sites were left as-is.

Also removes redundant min_revit_version keys from bundle.yaml files when the floor is 2014/2016/2019 (always satisfied on Revit 2021+). 2022+ minima and the empty test-bundle schema keys are unchanged.

Checklist

  • Code follows the PEP 8 style guide.
  • Code has been formatted with Black (style left matching surrounding files; IronPython 2.7).
  • Changes are tested and verified to work as expected.

Related Issues

Follow-up to #3438, as noted in #3438 (comment)

Additional Notes

Quoted related leftovers not in this PR (C# preprocessor, still-live Python gates):

  • Runtime #if REVIT2013 … REVIT2020 branches in dev/pyRevitLabs.PyRevit.Runtime/ (EventTelemetry.cs, EventHandling.cs, EventHooks.cs, ScriptCommands.cs, ScriptConsoleUtils.cs, CLREngine.cs, ContentEngine.cs, GrasshopperEngine.cs, plus RevitThemeDetector.cs). Those can be a separate cleanup.
  • Remaining Python version gates that are still meaningful: is_newer_than(2021) (2022+), 2022 / 2022, or_equal=True, 2024, 2026, is_older_than(2023), is_older_than(2027), is_exactly(2021) / is_exactly('2022').
  • Remaining min_revit_version values that still hide tools on older hosts: 2022, 2023, 2025, 2027.
  • docs/llms-full.txt still mirrors the old snippets and should be regenerated, not edited by hand.
Open in Web Open in Cursor 

After dropping Revit 2013-2020, HOST_APP.is_newer_than checks against
those versions (and equivalent is_older_than / version comparisons)
are always true or always false. Keep the supported-API path and drop
the legacy branches, including the unused MatchConfigWindowLegacy UI.

Co-authored-by: Jean-Marc Couffin <jmcouffin@users.noreply.github.com>

@devloai devloai Bot left a comment

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.

PR Summary:

Removes dead pre-2021 HOST_APP version checks across pyrevitlib and bundled extensions, following the drop of Revit 2013–2020 in #3438. Unwraps always-true/always-false is_newer_than/is_older_than/version gates, keeping live gates (2022+, 2024+, 2026+) and is_newer_than(2021) without or_equal. Deletes the unused MatchConfigWindowLegacy UI (XAML + resource dictionaries) and updates the csproj and installer manifest.

Review Summary:

Verified all 36 changed files against IronPython 2.7 constraints, black formatting, and PEP 8 naming conventions. All removed version gates were confirmed dead given the 2021 minimum host. Unused HOST_APP/UI imports were correctly cleaned up; HOST_APP was kept where still needed (e.g., is_newer_than(2021) in Make Pattern, is_newer_than(2022) in Print Sheets). The MatchConfigWindowLegacy removal is complete across all artifacts. One low-severity comment: get_connected_circuits implicitly returns None despite a list docstring contract — not a regression but worth making explicit.

Suggestions

  • Regenerate docs/llms-full.txt to reflect the removed version-gate snippets, as noted in the PR description. Apply
  • Clean up the remaining C# preprocessor REVIT2013–REVIT2020 branches in dev/pyRevitLabs.PyRevit.Runtime/ in a follow-up PR. Apply

x
for x in element.MEPModel.GetElectricalSystems()
if x.CircuitType in circuit_types
]

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.

The docstring (line 2103) declares the return type as list, but after unwrapping the version gate this function implicitly returns None when element.MEPModel is falsy or GetElectricalSystems() is empty. This matches the pre-PR behavior (both branches were inside the same if), so it's not a regression — but since you're touching this function, consider adding an explicit return [] after the if block so the actual return type matches the documented contract:

    if element.MEPModel and element.MEPModel.GetElectricalSystems():
        return [
            x
            for x in element.MEPModel.GetElectricalSystems()
            if x.CircuitType in circuit_types
        ]
    return []

⚡ Apply quick fix

actions

Quick Fix: Apply a small focused fix for this specific issue (takes < 1min).

Feedback: Rate this comment to help me improve future code reviews:

  • 👍 Good - Helpful and accurate
  • 👎 Poor - Wrong, unclear, or unhelpful
  • Skip if you don't have any strong opinions either way.

Copilot AI left a comment

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.

Pull request overview

This PR is a follow-up to #3438 (which dropped Revit 2013–2020 support). With a minimum supported host of Revit 2021, it removes HOST_APP.is_newer_than / is_older_than / HOST_APP.version comparisons in pyrevitlib and bundled extensions that are now always-true or always-false, keeping only the supported-API branch. It also deletes the obsolete MatchConfigWindowLegacy UI (XAML + localized resource dictionaries) and its packaging references.

Changes:

  • Unwrap always-true gates (e.g. is_newer_than(2015..2019)) to keep the modern-API path, and drop always-false branches (e.g. is_older_than(2018/2019), version <= 2020), removing now-unused HOST_APP imports where appropriate.
  • Delete MatchConfigWindowLegacy.xaml and its 8 localized resource dictionaries, and always load MatchConfigWindow.xaml; remove its entries from pyrevit.aip and pyRevitWPFForms.csproj.
  • Simplify core host logic in pyrevit/__init__.py (subversion, build, proc_window, pretty_name) since 2021+ always has the modern APIs.

Verification highlights: all removed from pyrevit import HOST_APP imports were confirmed unused in their files; files that only changed code (ColorSplasher, Make Pattern, ribbon, query, Print Sheets, etc.) retain valid HOST_APP usage; the collapsed create_param_value_filter and get_crop_region logic is preserved correctly; the Manage Tags block removed was unreachable code after a return; and no references to the deleted legacy window remain anywhere.

Reviewed changes

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

Show a summary per file
File Description
release/pyrevit.aip Removes installer row for deleted MatchConfigWindowLegacy.xaml
dev/pyRevitWPFForms/pyRevitWPFForms.csproj Removes Page include for deleted legacy XAML
pyrevitlib/pyrevit/init.py Simplifies subversion/build/proc_window/pretty_name; updates docstring example
pyrevitlib/pyrevit/runtime/init.py Unconditionally adds AvalonDock reference
pyrevitlib/pyrevit/revit/tabs.py Unwraps always-true 2018 gate in init_doc_colorizer
pyrevitlib/pyrevit/revit/db/update.py Simplifies set_name/toggle_category_visibility/set_crop_region; drops HOST_APP import
pyrevitlib/pyrevit/revit/db/query.py Simplifies get_name/get_connected_circuits/get_fillpattern/get_crop_region
pyrevitlib/pyrevit/revit/db/create.py Simplifies view naming and create_param_value_filter rule handling
pyrevitlib/pyrevit/revit/db/init.py Removes obsolete pre-2017 comment
pyrevitlib/pyrevit/loader/sessioninfo.py Always sets app version env var from subversion
pyrevitlib/pyrevit/labs.py Removes pre-2019 binding resolver activation and HOST_APP import
pyrevitlib/pyrevit/coreutils/ribbon.py Defaults tooltip video to .mp4; unwraps split-button 2017 guard
pyrevitlib/pyrevit/coreutils/applocales.py Always appends English_GB locale
extensions/.../Wipe Data Schema/script.py Always uses doc.EraseSchemaAndAllEntities
extensions/.../Reload Links/script.py Always includes CAD Links and shows selector
extensions/.../Override VG/script.py Uses only modern foreground-pattern API
extensions/.../ColorizeGroupTypes/script.py Uses only modern override-graphics API
extensions/.../Make Pattern/script.py, patmaker.py Unwrap 2014/2018 gates for scale text and filled region
extensions/.../Match/script.py, config.py Use only modern pattern APIs; always load non-legacy window
extensions/.../Match/MatchConfigWindowLegacy*.xaml Deletes legacy window and localized resource dictionaries
extensions/.../Remove Underlay/script.py Always uses SetUnderlayRange
extensions/.../Find Views By Filter/script.py Uses only modern underlay-parameter path
extensions/.../Copy Views/script.py Always uses ActiveGraphicalView path
extensions/.../Print Sheets/script.py Defaults export encoding to utf_8
extensions/.../ColorSplasher/script.py Always enables background-pattern option
extensions/pyRevitTags.../Manage Tags/script.py Removes unreachable post-return version branch
extensions/pyRevitTags.../lib/tagsmgr.py Inlines fabrication centerline categories into skip list

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Wurschdhaud

Copy link
Copy Markdown
Contributor

bundle.yaml files with the 'min_revit_version' flag set can also be updated. Would fit into this PR, as it also touches tools, not .cs

bundle.yaml minimums of 2014/2016/2019 are always satisfied now that
pyRevit requires Revit 2021+. Leave 2022+ gates and the empty test
bundle schema keys unchanged.

Co-authored-by: Jean-Marc Couffin <jmcouffin@users.noreply.github.com>
@romangolev

Copy link
Copy Markdown
Member

also connected with #3545
2 follow-ups so far for #3438

@romangolev romangolev self-assigned this Aug 19, 2026
Remove the pre-2017 version branch in GetUIApplication along with the now-unused NEW_UIAPP_FIELD_VERSION and LEGACY_UIAPP_FIELD constants, since the minimum supported Revit version no longer requires the legacy m_application field lookup.
Strip REVIT2013..REVIT2020 preprocessor checks and their fallbacks across the pyRevitLabs.PyRevit.Runtime project since those Revit versions are no longer supported, and tighten the loader theme detector's UIThemeManager gate to REVIT2021+.
@romangolev

Copy link
Copy Markdown
Member

@jmcouffin found some more dead code, committed here

@Wurschdhaud

Copy link
Copy Markdown
Contributor

Runtime #if REVIT2013 … REVIT2020 branches in dev/pyRevitLabs.PyRevit.Runtime/ (EventTelemetry.cs, EventHandling.cs, EventHooks.cs, ScriptCommands.cs, ScriptConsoleUtils.cs, CLREngine.cs, ContentEngine.cs, GrasshopperEngine.cs, plus RevitThemeDetector.cs). Those can be a separate cleanup.

So that's this stuff cursor mentioned?

@romangolev

Copy link
Copy Markdown
Member

@Wurschdhaud oops, my bad. I'm going to revert them now and open separate PR for that. I think we after that it's going to be safe to mark this PR as a ready for review

@romangolev
romangolev marked this pull request as ready for review August 25, 2026 09:32

@Wurschdhaud Wurschdhaud left a comment

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.

Tested some of them, didn't manage to break it. LGTM

@jmcouffin
jmcouffin merged commit d9ea528 into develop Aug 25, 2026
@jmcouffin
jmcouffin deleted the cursor/remove-dead-host-version-checks-2580 branch August 25, 2026 16:33
@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

@github-actions

Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 7.0.0.26237+2139

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.

5 participants