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

Warning fixes #11520

Merged
merged 3 commits into from
Nov 13, 2023
Merged

Conversation

dbnicholson
Copy link
Contributor

Summary

Running kolibri with PYTHONWARNINGS=all shows several warnings. This PR fixes the ones within Kolibri (there are several others in dependencies) that I saw.

References

None, just something I saw. Here is the original log I used to guide the changes.

Reviewer guidance

There should be no functional changes here, so just running Kolibri as usual to see if there are any regressions should be enough.


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

Running with PYTHONWARNINGS=all reveals:

```
<venv>/lib/python3.9/site-packages/kolibri/utils/server.py:881: ResourceWarning: unclosed file <_io.TextIOWrapper name='<homedir>/server.pid' mode='r' encoding='UTF-8'>
  pid_file_lines = open(filename, "r").readlines()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
```
Running with PYTHONWARNINGS=all reveals:

```
<venv>/kolibri/utils/main.py:100: ResourceWarning: unclosed file <_io.TextIOWrapper name='<homedir>/.data_version' mode='r' encoding='UTF-8'>
  version = open(version_file(), "r").read()
```
Running with PYTHONWARNINGS=all reveals several deprecation warnings
that `on_delete` must be specified for `ForeignKey` fields:

```
RemovedInDjango20Warning: on_delete will be a required arg for
ForeignKey in Django 2.0. Set it to models.CASCADE on models and in
existing migrations if you want to maintain the current default
behavior. See https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ForeignKey.on_delete
```
@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... SIZE: medium labels Nov 10, 2023
@rtibbles
Copy link
Member

The modified code would either show an issue with no migrations (the migrations already have the cascade set), or have test coverage, so I don't see any concerns here.

The cascade behaviour is most important for future Django upgrades once we drop Python 2.7 support.

@rtibbles
Copy link
Member

Smoke test locally running Kolibri shows no issues.

@rtibbles rtibbles merged commit d85865c into learningequality:release-v0.16.x Nov 13, 2023
35 checks passed
@dbnicholson dbnicholson deleted the warning-fixes branch December 7, 2023 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants