Skip to content

Commit 3343536

Browse files
authored
Python 3.9 upgrade (#1827)
* 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
1 parent 694bfac commit 3343536

File tree

122 files changed

+98
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+98
-524
lines changed

Diff for: Vagrantfile

-21
This file was deleted.

Diff for: base-requirements.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ django-pipeline==1.6.14
33
django-sitetree==1.10.0
44
Django==2.0.13
55
docutils==0.12
6-
Markdown==2.5.2
6+
Markdown==3.3.4
77
cmarkgfm==0.4.2
8-
Pillow==5.1.0
9-
psycopg2==2.7.3.2
8+
Pillow==8.3.1
9+
psycopg2==2.8.6
1010
python3-openid==3.1.0
1111
# lxml used by BeautifulSoup.
12-
lxml==4.1.1
12+
lxml==4.6.3
1313
cssselect==0.9.1
14-
feedparser==5.2.1
14+
feedparser==6.0.8
1515
beautifulsoup4==4.6.0
1616
icalendar==3.8.4
17-
chardet2==2.0.3
17+
chardet==4.0.0
1818
# TODO: We may drop 'django-imagekit' completely.
1919
django-imagekit==4.0.2
2020
git+https://github.com/django-haystack/django-haystack.git@802b0f6f4b3b99314453261876a32bac2bbec94f
@@ -25,7 +25,7 @@ django-tastypie==0.14.1
2525
pytz==2017.2
2626
python-dateutil==2.8.1
2727

28-
requests[security]>=2.20.0
28+
requests[security]>=2.26.0
2929

3030
django-honeypot==0.6.0
3131
django-markupfield==1.4.3

Diff for: blogs/migrations/0001_initial.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52
import django.utils.timezone
63
from django.conf import settings

Diff for: blogs/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def text_from_html(body):
2727
soup = BeautifulSoup(body, "html.parser")
2828
texts = soup.findAll(text=True)
2929
visible_texts = filter(tag_visible, texts)
30-
return u" ".join(t.strip() for t in visible_texts)
30+
return " ".join(t.strip() for t in visible_texts)
3131

3232

3333
class BlogEntry(models.Model):

Diff for: blogs/tests/test_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BlogParserTest(unittest.TestCase):
1111
def setUpClass(cls):
1212
super().setUpClass()
1313
cls.test_file_path = get_test_rss_path()
14-
cls.entries = get_all_entries("file://{}".format(cls.test_file_path))
14+
cls.entries = get_all_entries(f"file://{cls.test_file_path}")
1515

1616
def test_entries(self):
1717
self.assertEqual(len(self.entries), 25)

Diff for: boxes/migrations/0001_initial.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52
import markupfield.fields
63
import django.utils.timezone

Diff for: boxes/migrations/0002_auto_20150416_1853.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52

63

Diff for: boxes/migrations/0003_auto_20171101_2138.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.5 on 2017-11-01 21:38
3-
from __future__ import unicode_literals
42

53
from django.db import migrations
64

Diff for: cms/management/commands/create_initial_data.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def collect_initial_data_functions(self, app_label):
3535
app_list = apps.get_app_configs()
3636
for app in app_list:
3737
try:
38-
factory_module = importlib.import_module('{}.factories'.format(app.name))
38+
factory_module = importlib.import_module(f'{app.name}.factories')
3939
except ImportError:
4040
continue
4141
else:
@@ -50,7 +50,7 @@ def output(self, app_name, verbosity, *, done=False, result=False):
5050
if done:
5151
self.stdout.write(self.style.SUCCESS('DONE'))
5252
else:
53-
self.stdout.write('Creating initial data for {!r}... '.format(app_name), ending='')
53+
self.stdout.write(f'Creating initial data for {app_name!r}... ', ending='')
5454
if verbosity >= 2 and result:
5555
pprint.pprint(result)
5656

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

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

@@ -106,7 +106,7 @@ def handle(self, **options):
106106
try:
107107
result = function()
108108
except Exception as exc:
109-
self.stdout.write(self.style.ERROR('{}: {}'.format(type(exc).__name__, exc)))
109+
self.stdout.write(self.style.ERROR(f'{type(exc).__name__}: {exc}'))
110110
continue
111111
else:
112112
self.output(app_name, verbosity, done=True, result=result)

Diff for: codesamples/migrations/0001_initial.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52
import markupfield.fields
63
import django.utils.timezone

Diff for: codesamples/migrations/0002_auto_20150416_1853.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52

63

Diff for: codesamples/migrations/0003_auto_20170821_2000.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import migrations, models
52

63

Diff for: community/migrations/0001_initial.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52
import django.contrib.postgres.fields.jsonb
63
import markupfield.fields

Diff for: community/migrations/0001_squashed_0004_auto_20170831_0541.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.9.13 on 2017-08-31 05:44
3-
from __future__ import unicode_literals
42

53
from django.conf import settings
64
import django.contrib.postgres.fields.jsonb

Diff for: community/migrations/0002_auto_20150416_1853.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52

63

Diff for: community/migrations/0003_auto_20170831_0358.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.9.13 on 2017-08-31 03:58
3-
from __future__ import unicode_literals
42

53
import django.contrib.postgres.fields.jsonb
64
from django.db import migrations

Diff for: community/migrations/0004_auto_20170831_0541.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.9.13 on 2017-08-31 05:41
3-
from __future__ import unicode_literals
42

53
import django.contrib.postgres.fields.jsonb
64
from django.db import migrations

Diff for: community/models.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Meta:
5050
ordering = ['-created']
5151

5252
def __str__(self):
53-
return 'Post {} ({})'.format(self.get_media_type_display(), self.pk)
53+
return f'Post {self.get_media_type_display()} ({self.pk})'
5454

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

7575
def __str__(self):
76-
return 'Link ({})'.format(self.pk)
76+
return f'Link ({self.pk})'
7777

7878

7979
class Photo(ContentManageable):
@@ -96,7 +96,7 @@ class Meta:
9696
ordering = ['-created']
9797

9898
def __str__(self):
99-
return 'Photo ({})'.format(self.pk)
99+
return f'Photo ({self.pk})'
100100

101101

102102
class Video(ContentManageable):
@@ -119,4 +119,4 @@ class Meta:
119119
ordering = ['-created']
120120

121121
def __str__(self):
122-
return 'Video ({})'.format(self.pk)
122+
return f'Video ({self.pk})'

Diff for: community/templatetags/community.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def render_template_for(obj, template=None, template_directory=None):
4141
template_dirs.append('community/types')
4242

4343
for directory in template_dirs:
44-
template_list.append('{}/{}.html'.format(directory, obj.get_media_type_display()))
45-
template_list.append('{}/default.html'.format(directory))
44+
template_list.append(f'{directory}/{obj.get_media_type_display()}.html')
45+
template_list.append(f'{directory}/default.html')
4646

4747
output = render_to_string(template_list, context)
4848
return output

Diff for: companies/migrations/0001_initial.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52
import markupfield.fields
63

Diff for: companies/migrations/0002_auto_20150416_1853.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52

63

Diff for: companies/migrations/0003_auto_20170814_0301.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import migrations, models
52

63

Diff for: companies/migrations/0004_auto_20170821_2000.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import migrations, models
52

63

Diff for: docs/source/conf.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
import sys
54
import os

Diff for: docs/source/install.rst

+1-55
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,6 @@
11
Installing
22
==========
33

4-
Here are two ways to hack on python.org:
5-
6-
1. :ref:`vagrant-setup`
7-
2. :ref:`manual-setup`
8-
9-
.. _vagrant-setup:
10-
11-
Easy setup using Vagrant
12-
------------------------
13-
14-
First, install Vagrant_ (2.0+) and Ansible_ (2.0+) on your machine.
15-
You should then be able to provision the Vagrant box.
16-
17-
::
18-
19-
$ vagrant up
20-
21-
The box will be provisioned with a latest Python 3.6 version, a virtual
22-
environment with all the requirements installed, and a database ready to use.
23-
24-
Once this is done it's time to create some data and start the development server
25-
for the first time::
26-
27-
# SSH into the Vagrant box.
28-
$ vagrant ssh
29-
# Go to the pythondotorg/ directory and activate the virtual environment.
30-
$ cd ~/pythondotorg
31-
$ . venv/bin/activate
32-
# Create initial data for the most used applications (optional).
33-
$ ./manage.py create_initial_data
34-
# Set a password for the superuser "cbiggles". This username and password
35-
# can be used to login to the admin environment.
36-
$ ./manage.py changepassword cbiggles
37-
# Run the server.
38-
$ ./manage.py runserver 0.0.0.0:8000
39-
40-
Now use your favorite browser to go to http://localhost:8001/. The admin pages
41-
can be found at http://localhost:8001/admin/. You can use your superuser
42-
credentials to log in to Django admin.
43-
44-
You will only need to run the following five commands the next time you want to
45-
work on python.org::
46-
47-
$ vagrant up
48-
$ vagrant ssh
49-
$ cd ~/pythondotorg
50-
$ . venv/bin/activate
51-
$ ./manage.py runserver 0.0.0.0:8000
52-
53-
.. _Vagrant: https://www.vagrantup.com/downloads.html
54-
.. _Ansible: https://docs.ansible.com/ansible/intro_installation.html
55-
56-
.. _manual-setup:
57-
584
Manual setup
595
------------
606

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

6511
Then create a virtual environment::
6612

67-
$ python3.6 -m venv venv
13+
$ python3.9 -m venv venv
6814

6915
And then you'll need to install dependencies. You don't need to use ``pip3``
7016
inside a Python 3 virtual environment::

Diff for: downloads/migrations/0001_initial.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52
import markupfield.fields
63
import django.utils.timezone

Diff for: downloads/migrations/0002_auto_20150416_1853.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52

63

Diff for: downloads/migrations/0003_auto_20150824_1612.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import models, migrations
52

63

Diff for: downloads/migrations/0004_auto_20170821_2000.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
41
from django.db import migrations, models
52

63

Diff for: downloads/migrations/0005_move_release_page_content.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.4 on 2017-09-23 10:13
3-
from __future__ import unicode_literals
42

53
from django.db import migrations
64

Diff for: downloads/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def purge_fastly_download_pages(sender, instance, **kwargs):
256256
purge_url('/downloads/source/')
257257
purge_url('/downloads/windows/')
258258
if instance.get_version() is not None:
259-
purge_url('/ftp/python/{}/'.format(instance.get_version()))
259+
purge_url(f'/ftp/python/{instance.get_version()}/')
260260
# See issue #584 for details
261261
purge_url('/box/supernav-python-downloads/')
262262
purge_url('/box/homepage-downloads/')

0 commit comments

Comments
 (0)