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

bug fix: last pr had issue if venv wasn't being utilized #56

Merged
merged 6 commits into from
Dec 31, 2024

Conversation

Naggafin
Copy link
Contributor

I am sorry my friend! I found a bug in my code from my previous pr. if one wasn't using a venv (and using python at root level instead), the check against project dir would always fail. additionally, I made a mistake in the if statement that checked whether or not a form should be verified (I should have grouped the or operand). this pr fixes these errors. forgive my mistakes! :(

django_fastdev/apps.py Outdated Show resolved Hide resolved
# just in case venv resides in project dir
if venv_dir and module_path.startswith(str(venv_dir)):
return False
return True
Copy link
Owner

Choose a reason for hiding this comment

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

This new code is not what I suggested, and it's broken. It implicitly returns None.

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 confused, you me the if venv_dir bit? I just use implicit truthy testing in case somehow venv_dir is an empty string (using is None would cause that check to pass, and then startswith() would always succeed since it is being passed a blank string)

Copy link
Owner

Choose a reason for hiding this comment

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

No, I mean your code is like:

def foo():
    if x: 
        return True
   # NO ELSE HERE

That's the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhh, duh! fixed, sorry! :P

@@ -83,6 +83,15 @@ def get_gitignore_path():
return None


def get_venv_path():
return os.environ.get("VIRTUAL_ENV", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand this PR is moving this code around instead of adding it, but I wanted to point out that this usage of VIRTUAL_ENV as an env var is probably unreliable (see #39 and #36).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! I did a little bit of research to reliably determine the best ways to get the venv path, and chained them all into the get_venv_path() func now. should be hard to find a scenario where it won't pick up now I think

@boxed boxed merged commit d626399 into boxed:master Dec 31, 2024
1 check passed
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.

3 participants