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

Add missing import / requirement #988

Closed
wants to merge 1 commit into from

Conversation

jeffwidman
Copy link
Member

These are needed for the imports / requirements.

These are needed for the imports / requirements.
@@ -1,6 +1,7 @@
from django.contrib.auth.models import Group, User
from django.contrib.contenttypes.models import ContentType

import factory
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Several lines in this file use factory.X but the factory import itself was missing... eg:

object_id = factory.SelfAttribute('content_object.id')

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, yes good catch!

Copy link
Member

Choose a reason for hiding this comment

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

I don’t think that’s necessary.
https://docs.python.org/3/reference/simple_stmts.html#the-import-statement

import foo.bar.baz         # foo, foo.bar, and foo.bar.baz imported, foo bound locally

And indeed:

$ python
Python 3.10.8 (main, Oct 13 2022, 21:13:48) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import factory.django
>>> factory.LazyAttribute
<class 'factory.declarations.LazyAttribute'>

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh interesting, I either never realized that or long ago forgot that!

@@ -1 +1,2 @@
Django
factory_boy
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, the Flask examples need updating.

@jeffwidman
Copy link
Member Author

jeffwidman commented Nov 2, 2022

Closing as unnecessary per #988 (comment)

@jeffwidman jeffwidman closed this Nov 2, 2022
@jeffwidman jeffwidman deleted the add-missing-import-requirement branch November 2, 2022 16:50
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.

None yet

3 participants