Skip to content

Fix plugin loading type annotations and improve code readability#4524

Open
hariomphulre wants to merge 4 commits into
archlinux:masterfrom
hariomphulre:fix-3021-plugin
Open

Fix plugin loading type annotations and improve code readability#4524
hariomphulre wants to merge 4 commits into
archlinux:masterfrom
hariomphulre:fix-3021-plugin

Conversation

@hariomphulre
Copy link
Copy Markdown

Fix: Plugin loading with URL support

Issue: Plugin loading failed when using remote URLs due to Path normalization

Changes:

  1. args.py: Pass plugin argument as string to preserve URL format
  2. plugins.py:
    • Added urllib.error import for proper error handling
    • Updated _localize_path() to accept str | Path
    • Improved URL filename extraction using os.path.basename()
    • Added try-except for URL download errors
    • Updated load_plugin() to accept str | Path
    • Preserve URL strings throughout to avoid Path normalization

Impact:

  • Users can now load plugins from remote URLs (https://, http://)
  • Better error messages when downloads fail
  • Cleaner separation between string URLs and filesystem paths

@codefiles

@hariomphulre hariomphulre requested a review from Torxed as a code owner May 6, 2026 21:30
@hariomphulre
Copy link
Copy Markdown
Author

Hello, anyone can review it plz... @svartkanin @codefiles @Torxed

@ScarletEmanu
Copy link
Copy Markdown

Hi. A_Course_Wishes.cpp is empty. Was this intentional?

@hariomphulre
Copy link
Copy Markdown
Author

Hi. A_Course_Wishes.cpp is empty. Was this intentional?

ohh, its just bymistake created.

@hariomphulre
Copy link
Copy Markdown
Author

hariomphulre commented May 9, 2026

i deleted it.

@hariomphulre
Copy link
Copy Markdown
Author

@Torxed please review it.

@h8d13
Copy link
Copy Markdown
Contributor

h8d13 commented May 12, 2026

@hariomphulre what kind of tests have you tried for this patch?



def load_plugin(path: Path) -> None:
def load_plugin(path: str | Path) -> None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is no longer a Path so that should be removed

namespace: str | None = None
parsed_url = urllib.parse.urlparse(str(path))
# Keep URL as string to preserve scheme (avoid Path normalization)
path_str = str(path) if isinstance(path, Path) else path
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This can't be a Path anymore

Comment thread archinstall/lib/args.py
plugin_path = Path(args.plugin)
load_plugin(plugin_path)
# Pass plugin as string to preserve URL format (avoid Path normalization)
load_plugin(args.plugin)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At this point plugin can be either pointing to a local file or a url which does not correlate with the actual arg defintion

help='File path to a plugin to load',
.

Instead I'm proposing to introduce a --plugin-url instead to clearly differentiate between them. This also aligns with the config arguments

'--config-url',

@hariomphulre
Copy link
Copy Markdown
Author

Now check

Pass plugin paths as strings so HTTPS URLs are not mangled by pathlib.
Fix mixed tab/space indentation in ArchConfig.from_config that broke
imports. Harden plugin import (spec handling, failed-import cleanup),
and skip version comparison when version tuples are empty. Add tests
for URL handling and HTTP rejection.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hariomphulre
Copy link
Copy Markdown
Author

hariomphulre commented May 14, 2026

@Torxed @svartkanin hello, now plz review it and approve jobs

@hariomphulre hariomphulre requested a review from svartkanin May 14, 2026 21:25
@svartkanin
Copy link
Copy Markdown
Collaborator

What do you want me to review here? None of the comments have been addressed

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.

4 participants