Skip to content

Commit

Permalink
Python 3.9 upgrade (#1827)
Browse files Browse the repository at this point in the history
* Remove unmaintained Vagrant setup/instructions

* update python version to 3.9

* upgrade dependencies to reach python3.9 compatibility

* upgrade requests, migrate to latest chardet

* result of `pyupgrade --py3-plus --py39-plus
  • Loading branch information
ewdurbin authored Jul 28, 2021
1 parent 694bfac commit 3343536
Show file tree
Hide file tree
Showing 122 changed files with 98 additions and 524 deletions.
21 changes: 0 additions & 21 deletions Vagrantfile

This file was deleted.

14 changes: 7 additions & 7 deletions base-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ django-pipeline==1.6.14
django-sitetree==1.10.0
Django==2.0.13
docutils==0.12
Markdown==2.5.2
Markdown==3.3.4
cmarkgfm==0.4.2
Pillow==5.1.0
psycopg2==2.7.3.2
Pillow==8.3.1
psycopg2==2.8.6
python3-openid==3.1.0
# lxml used by BeautifulSoup.
lxml==4.1.1
lxml==4.6.3
cssselect==0.9.1
feedparser==5.2.1
feedparser==6.0.8
beautifulsoup4==4.6.0
icalendar==3.8.4
chardet2==2.0.3
chardet==4.0.0
# TODO: We may drop 'django-imagekit' completely.
django-imagekit==4.0.2
git+https://github.com/django-haystack/django-haystack.git@802b0f6f4b3b99314453261876a32bac2bbec94f
Expand All @@ -25,7 +25,7 @@ django-tastypie==0.14.1
pytz==2017.2
python-dateutil==2.8.1

requests[security]>=2.20.0
requests[security]>=2.26.0

django-honeypot==0.6.0
django-markupfield==1.4.3
Expand Down
3 changes: 0 additions & 3 deletions blogs/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django.utils.timezone
from django.conf import settings
Expand Down
2 changes: 1 addition & 1 deletion blogs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def text_from_html(body):
soup = BeautifulSoup(body, "html.parser")
texts = soup.findAll(text=True)
visible_texts = filter(tag_visible, texts)
return u" ".join(t.strip() for t in visible_texts)
return " ".join(t.strip() for t in visible_texts)


class BlogEntry(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion blogs/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BlogParserTest(unittest.TestCase):
def setUpClass(cls):
super().setUpClass()
cls.test_file_path = get_test_rss_path()
cls.entries = get_all_entries("file://{}".format(cls.test_file_path))
cls.entries = get_all_entries(f"file://{cls.test_file_path}")

def test_entries(self):
self.assertEqual(len(self.entries), 25)
Expand Down
3 changes: 0 additions & 3 deletions boxes/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import markupfield.fields
import django.utils.timezone
Expand Down
3 changes: 0 additions & 3 deletions boxes/migrations/0002_auto_20150416_1853.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


Expand Down
2 changes: 0 additions & 2 deletions boxes/migrations/0003_auto_20171101_2138.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-01 21:38
from __future__ import unicode_literals

from django.db import migrations

Expand Down
10 changes: 5 additions & 5 deletions cms/management/commands/create_initial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def collect_initial_data_functions(self, app_label):
app_list = apps.get_app_configs()
for app in app_list:
try:
factory_module = importlib.import_module('{}.factories'.format(app.name))
factory_module = importlib.import_module(f'{app.name}.factories')
except ImportError:
continue
else:
Expand All @@ -50,7 +50,7 @@ def output(self, app_name, verbosity, *, done=False, result=False):
if done:
self.stdout.write(self.style.SUCCESS('DONE'))
else:
self.stdout.write('Creating initial data for {!r}... '.format(app_name), ending='')
self.stdout.write(f'Creating initial data for {app_name!r}... ', ending='')
if verbosity >= 2 and result:
pprint.pprint(result)

Expand All @@ -74,7 +74,7 @@ def flush_handler(self, do_flush, verbosity):
try:
call_command('flush', verbosity=verbosity, interactive=False)
except Exception as exc:
self.stdout.write(self.style.ERROR('{}: {}'.format(type(exc).__name__, exc)))
self.stdout.write(self.style.ERROR(f'{type(exc).__name__}: {exc}'))
return confirm

def handle(self, **options):
Expand All @@ -92,7 +92,7 @@ def handle(self, **options):
try:
call_command('loaddata', 'sitetree_menus', '-v0')
except Exception as exc:
self.stdout.write(self.style.ERROR('{}: {}'.format(type(exc).__name__, exc)))
self.stdout.write(self.style.ERROR(f'{type(exc).__name__}: {exc}'))
else:
self.output('sitetree', verbosity, done=True)

Expand All @@ -106,7 +106,7 @@ def handle(self, **options):
try:
result = function()
except Exception as exc:
self.stdout.write(self.style.ERROR('{}: {}'.format(type(exc).__name__, exc)))
self.stdout.write(self.style.ERROR(f'{type(exc).__name__}: {exc}'))
continue
else:
self.output(app_name, verbosity, done=True, result=result)
3 changes: 0 additions & 3 deletions codesamples/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import markupfield.fields
import django.utils.timezone
Expand Down
3 changes: 0 additions & 3 deletions codesamples/migrations/0002_auto_20150416_1853.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


Expand Down
3 changes: 0 additions & 3 deletions codesamples/migrations/0003_auto_20170821_2000.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
3 changes: 0 additions & 3 deletions community/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django.contrib.postgres.fields.jsonb
import markupfield.fields
Expand Down
2 changes: 0 additions & 2 deletions community/migrations/0001_squashed_0004_auto_20170831_0541.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-08-31 05:44
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields.jsonb
Expand Down
3 changes: 0 additions & 3 deletions community/migrations/0002_auto_20150416_1853.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


Expand Down
2 changes: 0 additions & 2 deletions community/migrations/0003_auto_20170831_0358.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-08-31 03:58
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations
Expand Down
2 changes: 0 additions & 2 deletions community/migrations/0004_auto_20170831_0541.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-08-31 05:41
from __future__ import unicode_literals

import django.contrib.postgres.fields.jsonb
from django.db import migrations
Expand Down
8 changes: 4 additions & 4 deletions community/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Meta:
ordering = ['-created']

def __str__(self):
return 'Post {} ({})'.format(self.get_media_type_display(), self.pk)
return f'Post {self.get_media_type_display()} ({self.pk})'

def get_absolute_url(self):
return reverse('community:post_detail', kwargs={'pk': self.pk})
Expand All @@ -73,7 +73,7 @@ class Meta:
ordering = ['-created']

def __str__(self):
return 'Link ({})'.format(self.pk)
return f'Link ({self.pk})'


class Photo(ContentManageable):
Expand All @@ -96,7 +96,7 @@ class Meta:
ordering = ['-created']

def __str__(self):
return 'Photo ({})'.format(self.pk)
return f'Photo ({self.pk})'


class Video(ContentManageable):
Expand All @@ -119,4 +119,4 @@ class Meta:
ordering = ['-created']

def __str__(self):
return 'Video ({})'.format(self.pk)
return f'Video ({self.pk})'
4 changes: 2 additions & 2 deletions community/templatetags/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def render_template_for(obj, template=None, template_directory=None):
template_dirs.append('community/types')

for directory in template_dirs:
template_list.append('{}/{}.html'.format(directory, obj.get_media_type_display()))
template_list.append('{}/default.html'.format(directory))
template_list.append(f'{directory}/{obj.get_media_type_display()}.html')
template_list.append(f'{directory}/default.html')

output = render_to_string(template_list, context)
return output
3 changes: 0 additions & 3 deletions companies/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import markupfield.fields

Expand Down
3 changes: 0 additions & 3 deletions companies/migrations/0002_auto_20150416_1853.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


Expand Down
3 changes: 0 additions & 3 deletions companies/migrations/0003_auto_20170814_0301.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
3 changes: 0 additions & 3 deletions companies/migrations/0004_auto_20170821_2000.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import os
Expand Down
56 changes: 1 addition & 55 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -1,60 +1,6 @@
Installing
==========

Here are two ways to hack on python.org:

1. :ref:`vagrant-setup`
2. :ref:`manual-setup`

.. _vagrant-setup:

Easy setup using Vagrant
------------------------

First, install Vagrant_ (2.0+) and Ansible_ (2.0+) on your machine.
You should then be able to provision the Vagrant box.

::

$ vagrant up

The box will be provisioned with a latest Python 3.6 version, a virtual
environment with all the requirements installed, and a database ready to use.

Once this is done it's time to create some data and start the development server
for the first time::

# SSH into the Vagrant box.
$ vagrant ssh
# Go to the pythondotorg/ directory and activate the virtual environment.
$ cd ~/pythondotorg
$ . venv/bin/activate
# Create initial data for the most used applications (optional).
$ ./manage.py create_initial_data
# Set a password for the superuser "cbiggles". This username and password
# can be used to login to the admin environment.
$ ./manage.py changepassword cbiggles
# Run the server.
$ ./manage.py runserver 0.0.0.0:8000

Now use your favorite browser to go to http://localhost:8001/. The admin pages
can be found at http://localhost:8001/admin/. You can use your superuser
credentials to log in to Django admin.

You will only need to run the following five commands the next time you want to
work on python.org::

$ vagrant up
$ vagrant ssh
$ cd ~/pythondotorg
$ . venv/bin/activate
$ ./manage.py runserver 0.0.0.0:8000

.. _Vagrant: https://www.vagrantup.com/downloads.html
.. _Ansible: https://docs.ansible.com/ansible/intro_installation.html

.. _manual-setup:

Manual setup
------------

Expand All @@ -64,7 +10,7 @@ First, clone the repository::

Then create a virtual environment::

$ python3.6 -m venv venv
$ python3.9 -m venv venv

And then you'll need to install dependencies. You don't need to use ``pip3``
inside a Python 3 virtual environment::
Expand Down
3 changes: 0 additions & 3 deletions downloads/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import markupfield.fields
import django.utils.timezone
Expand Down
3 changes: 0 additions & 3 deletions downloads/migrations/0002_auto_20150416_1853.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


Expand Down
3 changes: 0 additions & 3 deletions downloads/migrations/0003_auto_20150824_1612.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


Expand Down
3 changes: 0 additions & 3 deletions downloads/migrations/0004_auto_20170821_2000.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
2 changes: 0 additions & 2 deletions downloads/migrations/0005_move_release_page_content.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-09-23 10:13
from __future__ import unicode_literals

from django.db import migrations

Expand Down
2 changes: 1 addition & 1 deletion downloads/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def purge_fastly_download_pages(sender, instance, **kwargs):
purge_url('/downloads/source/')
purge_url('/downloads/windows/')
if instance.get_version() is not None:
purge_url('/ftp/python/{}/'.format(instance.get_version()))
purge_url(f'/ftp/python/{instance.get_version()}/')
# See issue #584 for details
purge_url('/box/supernav-python-downloads/')
purge_url('/box/homepage-downloads/')
Expand Down
Loading

0 comments on commit 3343536

Please sign in to comment.