Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pm refactor #158

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bitwise-constructs
Copy link
Contributor

What I did

fixes: #

How I did it

How to verify it

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@bitwise-constructs
Copy link
Contributor Author

bitwise-constructs commented Jan 24, 2025

note: this was already protected from partial matches eclipsing full matches. the reason I'm adding this further check is in preparation of enriching the console error communication to distinguish between missing remapping and missing file. Currently it results in a nonsense path that doesn't get caught until attempted compile

@@ -207,7 +207,8 @@ def _resolve_import_remapping(self, project: "ProjectManager"):
# Get all matches.
valid_matches: list[tuple[str, str]] = []
for check_remap_key, check_remap_value in import_remapping.items():
if check_remap_key not in self.value:
# Match with a trailing slash to avoid partial matches.
if f"{check_remap_key}/" not in self.value:
Copy link
Member

Choose a reason for hiding this comment

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

What if it already ends with a trailing slash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to being convinced otherwise but then I'd say they're just doing it wrong. I only ever really encounter trailing slashes as a thing in web URLs, for instance if someone is making a git branch you wouldn't expect them to specify it as "feat/pm-refactor/"

But more validation never hurts, I can add a line to protect against this

Copy link
Member

Choose a reason for hiding this comment

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

remap/key/=value/key/

doesnt seem too far-fetched or invaliud. It seems worth just doing:

key_to_check = check_remap_key if check_remap_key.endswith("/") else f"{check_remap_key}/"
i key_to_check not in self.value:

ape_solidity/_models.py Show resolved Hide resolved
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.

2 participants