Skip to content

chore: Use codespell to fix typos in code.#4797

Merged
rjsparks merged 9 commits into
ietf-tools:mainfrom
larseggert:fix-typos-in-code
Dec 7, 2022
Merged

chore: Use codespell to fix typos in code.#4797
rjsparks merged 9 commits into
ietf-tools:mainfrom
larseggert:fix-typos-in-code

Conversation

@larseggert

Copy link
Copy Markdown
Collaborator

Second part of replacement of #4651

@rjsparks, I probably need to revert some things here, and I also still need to add that new migration - how do I do that?

Second part of replacement of ietf-tools#4651

@rjsparks, I probably need to revert some things here, and I also
still need to add that new migration - how do I do that?
@codecov

codecov Bot commented Nov 25, 2022

Copy link
Copy Markdown

Codecov Report

Merging #4797 (14526fe) into main (8cdf4ce) will decrease coverage by 0.00%.
The diff coverage is 80.64%.

@@            Coverage Diff             @@
##             main    #4797      +/-   ##
==========================================
- Coverage   88.46%   88.45%   -0.01%     
==========================================
  Files         296      296              
  Lines       39755    39755              
==========================================
- Hits        35169    35166       -3     
- Misses       4586     4589       +3     
Impacted Files Coverage Δ
ietf/api/views.py 89.47% <ø> (ø)
ietf/ietfauth/urls.py 100.00% <ø> (ø)
ietf/stats/views.py 93.10% <0.00%> (ø)
ietf/submit/forms.py 82.74% <0.00%> (ø)
ietf/utils/decorators.py 87.65% <0.00%> (ø)
ietf/utils/mail.py 79.62% <0.00%> (ø)
ietf/nomcom/forms.py 95.39% <50.00%> (ø)
ietf/mailinglists/models.py 89.65% <66.66%> (ø)
ietf/group/models.py 92.67% <100.00%> (ø)
ietf/ietfauth/forms.py 95.13% <100.00%> (ø)
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rjsparks

Copy link
Copy Markdown
Member

After you change the model, run ietf/manage.py makemigrations. If it gives the migration an inscrutable name, rename it (or just pass --name into the makemigrations invocation in the first place).

@larseggert

Copy link
Copy Markdown
Collaborator Author

I just tried ietf/manage.py makemigrations but it says No changes detected. Did I not change the model in the current PR?

@rjsparks

rjsparks commented Dec 1, 2022

Copy link
Copy Markdown
Member

Because you changed the names in the already existing migrations.

Changing already applied migrations is never the right thing to do (unless you plan to run the reverse and forward again on the production database). Since you changed ietf/mailinglists/migrations/0001_initial.py, Django thinks that the class has always been named Allowlisted, and doesn't know that it needs to make changes to the database.

@larseggert

Copy link
Copy Markdown
Collaborator Author

Thanks! I will try to fix next week.

@rjsparks

rjsparks commented Dec 2, 2022

Copy link
Copy Markdown
Member

To be clear, I think it's best to just revert all the existing migrations to what's in main.

@larseggert larseggert marked this pull request as ready for review December 5, 2022 14:29
Comment thread ietf/dbtemplate/fixtures/nomcom_templates.xml
Comment thread ietf/name/fixtures/names.json
email.save()
PersonEvent.objects.create(person=email.person, type='email_address_deactivated',
desc="Deactivated the email addres <%s>. Reason: %s" % (email.address, options['reason']) )
desc="Deactivated the email address <%s>. Reason: %s" % (email.address, options['reason']) )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will make PersonEvent objects created in the future correct, but will not change any that are already in the database.

>>> PersonEvent.objects.filter(desc__contains="addres ").count()
5640

To change those, we would need a data migration. (This would have a forward and a reverse, but the reverse should do nothing (just pass) as it doesn't make sense to go back to misspelled descriptions).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

How would I add one?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Several steps.

  • `ietf/manage.py makemigrations --empty --name=personevent_spelling person
  • Add a forward and reverse function to the empty migration it creates and wire them into migrations.RunPython (search for def forward( to find lots of examples.
  • update the dependencies list to the tip of any apps from which you end up pulling in the model. (You'll at least pull in PersonEvent from Person, using apps.get_model, not an import, but you'll get the right person dependency automatically given that you made the migration on the person app. Note also that what you get is a facade with a working object manager, not the actual class - member functions of the class will not be available).
  • the reverse should just pass. For the forward, you'll want to figure out how to iterate over the objects that have the spelling errors and update them as efficiently as you can (since however long this runs is downtime as the release it contains is deployed).

More to read at https://docs.djangoproject.com/en/2.2/topics/migrations/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think this is beyond my paygrade...

Comment thread ietf/static/js/document_relations.js
Comment thread ietf/utils/management/commands/coverage_changes.py Outdated
Comment thread ietf/utils/management/commands/coverage_changes.py
@larseggert larseggert requested a review from rjsparks December 5, 2022 18:01
Comment thread ietf/name/fixtures/names.json

@rjsparks rjsparks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

whoops - still need the migration for older PersonEvent objects (unless that's too much to ask - we can take this without it and go work that as a separate task.)

@jennifer-richards jennifer-richards left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missed renaming a method after fixing the same word in its code. Should fix that while in the area.

A couple other minor suggestions inline that can be taken or left as you prefer.

Comment thread ietf/group/models.py Outdated
Comment thread ietf/ietfauth/views.py Outdated
Comment thread ietf/mailinglists/migrations/0003_allowlisted.py
@rjsparks rjsparks merged commit 220be21 into ietf-tools:main Dec 7, 2022
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 11, 2022
@larseggert larseggert deleted the fix-typos-in-code branch December 15, 2022 15:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants