Skip to content

Fix/deferred attribute assignment#370

Closed
jarekwg wants to merge 4 commits intojazzband:masterfrom
jarekwg:fix/deferred-attribute-assignment
Closed

Fix/deferred attribute assignment#370
jarekwg wants to merge 4 commits intojazzband:masterfrom
jarekwg:fix/deferred-attribute-assignment

Conversation

@jarekwg
Copy link
Copy Markdown
Contributor

@jarekwg jarekwg commented May 1, 2019

Reverts #367
Adds a test for #331

PR also sneaks in some linter configs.

Issue not fixed here. I suspect it's a django issue. Findings reported in #331.

  • Update CHANGES.rst file to describe the changes, and quote according issue with GH-<issue_number>.

Copy link
Copy Markdown
Contributor

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

check the build failures

@jarekwg
Copy link
Copy Markdown
Contributor Author

jarekwg commented May 2, 2019

Yeah these failures are expected. Going to try see if the fix can be made in django itself. Just made PR now, to include failing test.
I guess, for the time being, the most useful fix would be #336, but it comes with its own edge cases that it fails to cover...

e: Here's the current status on the Django ticket: https://code.djangoproject.com/ticket/30427#ticket

@Natim
Copy link
Copy Markdown

Natim commented Aug 20, 2019

can you add a isort rule to the makefile too?

value = self.descriptor.__get__(instance, owner)
except AttributeError:
value = self.descriptor
value = self.descriptor.__get__(instance, owner)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
value = self.descriptor.__get__(instance, owner)
try:
value = self.descriptor.__get__(instance, owner)
except AttributeError:
value = self.descriptor

Copy link
Copy Markdown
Contributor Author

@jarekwg jarekwg Aug 20, 2019

Choose a reason for hiding this comment

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

Hey, this just reverts my changes?
I've already forgotten a lot of what was going on here, but I believe the try-catch was only a bandaid fix that caused other edge cases to fail.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ok thank you for your advice.

@jarekwg
Copy link
Copy Markdown
Contributor Author

jarekwg commented Aug 20, 2019

can you add a isort rule to the makefile too?

I've not used makefiles this way before, but can take a look when it's time to finally look into getting this merged in. I think we're blocked on django currently.

See my open ticket and PR with them here: https://code.djangoproject.com/ticket/30427#ticket
Helping get that merged in would allow us to fix the issue properly here.

@jarekwg
Copy link
Copy Markdown
Contributor Author

jarekwg commented Jan 8, 2024

Closing. Idk if this was addressed in the end by someone else somewhere else, but I don't have the resources to delve into here again.. ;/

@jarekwg jarekwg closed this Jan 8, 2024
mthuurne added a commit to ProtixIT/django-model-utils that referenced this pull request Jun 12, 2024
There used to be a [bug in Django](https://code.djangoproject.com/ticket/30427)
that caused these tests to fail, according to the discussion of jazzband#370.
That bug was fixed in Django 4.0.

However, because the test model was using a `FieldTracker`
rather than a `ModelTracker`, all model-specific test cases
in `ModelTrackerTests` continued to fail.
mthuurne added a commit to ProtixIT/django-model-utils that referenced this pull request Jun 12, 2024
This catch was introduced in jazzband#367, but subsequent discussion
in jazzband#370, jazzband#381 and jazzband#382 suggests that it wasn't the proper solution.

Now that `AbstractModelTrackerTests` is re-enabled and passing,
it becomes clear that `AttributeError` is no longer raised during
unit testing when using a recent Django version. Therefore I think
it is safe to remove the `try`/`except`.
mthuurne added a commit to ProtixIT/django-model-utils that referenced this pull request Jun 13, 2024
There used to be a [bug in Django](https://code.djangoproject.com/ticket/30427)
that caused these tests to fail, according to the discussion of jazzband#370.
That bug was fixed in Django 4.0.

However, because the test model was using a `FieldTracker`
rather than a `ModelTracker`, all model-specific test cases
in `ModelTrackerTests` continued to fail.
mthuurne added a commit to ProtixIT/django-model-utils that referenced this pull request Jun 13, 2024
This catch was introduced in jazzband#367, but subsequent discussion
in jazzband#370, jazzband#381 and jazzband#382 suggests that it wasn't the proper solution.

Now that `AbstractModelTrackerTests` is re-enabled and passing,
it becomes clear that `AttributeError` is no longer raised during
unit testing when using a recent Django version. Therefore I think
it is safe to remove the `try`/`except`.
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