Skip to content

Commit

Permalink
Remove support for end-of-life Python 2.7 (#1098)
Browse files Browse the repository at this point in the history
Python 2.7 went end of life at the end of 2019. It is no longer
receiving updates including for security issues.

Removing Python 2.7 support reduces testing resources and removes the
need to maintain compatibility shims.

- Remove unnecessary dependencies six and ipaddress.
- Remove unnecessary test dependencies: mock, more-itertools.
- Unpin random2 test dependency.
- Run pyupgrade to cleanup syntax.

As the project no longer supports Python 2, the wheel should no longer
be designated as "universal" and so setup.cfg has been updated. The
wheel can continue to be built for Python 3 only.

Fixes #1063

Co-authored-by: Flavio Curella <[email protected]>
  • Loading branch information
jdufresne and fcurella committed Jan 14, 2020
1 parent 96a7bbc commit 6e4a09e
Show file tree
Hide file tree
Showing 416 changed files with 402 additions and 1,837 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ matrix:
- python: 3.7
env: TOXENV=checkmanifest
- env: TOXENV=isort
- python: 2.7
env: TOXENV=py27
- python: 3.5
env: TOXENV=py35
- python: 3.6
Expand All @@ -23,8 +21,6 @@ matrix:
env: TOXENV=py37
- python: 3.8
env: TOXENV=py38
- python: pypy2.7-6.0
env: TOXENV=pypy
- python: pypy3.5-6.0
env: TOXENV=pypy3
- python: 3.7
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

UNRELEASED
----------

* Breaking change: Remove support for end-of-life Python 2.7.

`3.0.1 - 14-January-2019 <https://github.com/joke2k/faker/compare/v3.0.0...v3.0.1>`__
-------------------------------------------------------------------------------------

Expand All @@ -17,6 +22,7 @@ Changelog
* Add ``NIP`` generator in ``pl_PL``. Thanks @IlfirinPL.
* Fix ``Faker.random_number`` intermittent exceptions. Thanks @Jengah.


`3.0.0 - 04-December-2019 <https://github.com/joke2k/faker/compare/v2.0.5...v3.0.0>`__
--------------------------------------------------------------------------------------

Expand Down
9 changes: 0 additions & 9 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
build: false

environment:
PYTHONIOENCODING: "utf-8"
matrix:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.x"
PYTHON_ARCH: "32"
Expand All @@ -24,10 +19,6 @@ environment:
PYTHON_VERSION: "3.8.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5.x"
PYTHON_ARCH: "64"
Expand Down
9 changes: 0 additions & 9 deletions docs/coding_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ Lines length should not exceed 120 characters. Please use trailing commas.
You can find our complete flake8 configuration in the tox.ini_ file.


Encoding
--------

Every Python source file should be encoded as UTF-8.
As per `PEP 263`_, the first or the second line must be::

# coding=utf-8


Data Sets
---------

Expand Down
17 changes: 8 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Faker documentation build configuration file, created by
# sphinx-quickstart on Tue Mar 11 11:25:48 2014.
Expand Down Expand Up @@ -43,8 +42,8 @@
master_doc = 'index'

# General information about the project.
project = u'Faker'
copyright = u'2014, Daniele Faraglia'
project = 'Faker'
copyright = '2014, Daniele Faraglia'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -196,8 +195,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'Faker.tex', u'Faker Documentation',
u'Daniele Faraglia', 'manual'),
('index', 'Faker.tex', 'Faker Documentation',
'Daniele Faraglia', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -226,8 +225,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'faker', u'Faker Documentation',
[u'Daniele Faraglia'], 1)
('index', 'faker', 'Faker Documentation',
['Daniele Faraglia'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -240,8 +239,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Faker', u'Faker Documentation',
u'Daniele Faraglia', 'Faker', 'One line description of project.',
('index', 'Faker', 'Faker Documentation',
'Daniele Faraglia', 'Faker', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
2 changes: 0 additions & 2 deletions faker/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding=utf-8

if __name__ == "__main__":
from faker.cli import execute_from_command_line
execute_from_command_line()
12 changes: 3 additions & 9 deletions faker/build_docs.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# coding=utf-8

from __future__ import print_function, unicode_literals

import os
import pprint
import sys

import six

DOCS_ROOT = os.path.abspath(os.path.join('..', 'docs'))


def write(fh, s):
return fh.write(s.encode('utf-8'))
return fh.write(s.encode())


def write_base_provider(fh, doc, base_provider):
Expand All @@ -39,7 +33,7 @@ def write_provider(fh, doc, provider, formatters, excludes=None):
# `pprint` can't format sets of heterogenous types.
if not isinstance(example, set):
example = pprint.pformat(example, indent=4)
lines = six.text_type(example).expandtabs().splitlines()
lines = str(example).expandtabs().splitlines()
except UnicodeEncodeError:
msg = 'error on "{}" with value "{}"'.format(signature, example)
raise Exception(msg)
Expand Down Expand Up @@ -120,7 +114,7 @@ def _main(app, *args, **kwargs):


def setup(app):
app.connect(str('builder-inited'), _main)
app.connect('builder-inited', _main)


if __name__ == "__main__":
Expand Down
10 changes: 2 additions & 8 deletions faker/cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
# coding=utf-8

from __future__ import print_function, unicode_literals

import argparse
import logging
import os
import random
import sys

import six

from faker import VERSION, Faker, documentor
from faker.config import AVAILABLE_LOCALES, DEFAULT_LOCALE, META_PROVIDERS_MODULES

Expand All @@ -30,7 +24,7 @@ def print_provider(doc, provider, formatters, excludes=None, output=None):
if signature in excludes:
continue
try:
lines = six.text_type(example).expandtabs().splitlines()
lines = str(example).expandtabs().splitlines()
except UnicodeDecodeError:
# The example is actually made of bytes.
# We could coerce to bytes, but that would fail anyway when we wiil
Expand Down Expand Up @@ -114,7 +108,7 @@ def print_doc(provider_or_field=None,
print_provider(d, p, fs, output=output)


class Command(object):
class Command:

def __init__(self, argv=None):
self.argv = argv or sys.argv[:]
Expand Down
27 changes: 0 additions & 27 deletions faker/compat.py

This file was deleted.

1 change: 0 additions & 1 deletion faker/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding=utf-8
from importlib import import_module

from faker.utils.loading import find_available_locales, find_available_providers
Expand Down
16 changes: 4 additions & 12 deletions faker/documentor.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# coding=utf-8

from __future__ import unicode_literals

import inspect

from faker import utils

from .compat import getargspec


class Documentor(object):
class Documentor:

def __init__(self, generator):
"""
Expand Down Expand Up @@ -58,7 +50,7 @@ def get_provider_formatters(self, provider, prefix='fake.',

if with_args:
# retrieve all parameter
argspec = getargspec(method)
argspec = inspect.getfullargspec(method)

lst = [x for x in argspec.args if x not in ['self', 'cls']]
for i, arg in enumerate(lst):
Expand All @@ -67,8 +59,8 @@ def get_provider_formatters(self, provider, prefix='fake.',

try:
default = argspec.defaults[i]
if utils.is_string(default):
default = utils.quote(default)
if isinstance(default, str):
default = repr(default)
else:
# TODO check default type
default = "{}".format(default)
Expand Down
6 changes: 1 addition & 5 deletions faker/factory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# coding=utf-8

from __future__ import absolute_import, unicode_literals

import locale as pylocale
import logging
import sys
Expand All @@ -22,7 +18,7 @@
logger.debug('Not in REPL -> leaving logger event level as is.')


class Factory(object):
class Factory:

@classmethod
def create(
Expand Down
10 changes: 2 additions & 8 deletions faker/generator.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# coding=utf-8

from __future__ import unicode_literals

import random as random_module
import re

import six

_re_token = re.compile(r'\{\{(\s?)(\w+)(\s?)\}\}')
random = random_module.Random()
mod_random = random # compat with name released in 0.8


class Generator(object):
class Generator:

__config = {}

Expand Down Expand Up @@ -110,5 +104,5 @@ def parse(self, text):

def __format_token(self, matches):
formatter = list(matches.groups())
formatter[1] = six.text_type(self.format(formatter[1]))
formatter[1] = str(self.format(formatter[1]))
return ''.join(formatter)
4 changes: 1 addition & 3 deletions faker/providers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding=utf-8

import re
import string

Expand All @@ -15,7 +13,7 @@
_re_cir = re.compile(r'\^')


class BaseProvider(object):
class BaseProvider:

__provider__ = 'base'
__lang__ = None
Expand Down
3 changes: 0 additions & 3 deletions faker/providers/address/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding=utf-8
from __future__ import unicode_literals

from .. import BaseProvider, date_time

localized = True
Expand Down
3 changes: 0 additions & 3 deletions faker/providers/address/cs_CZ/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding=utf-8
from __future__ import unicode_literals

from .. import Provider as AddressProvider


Expand Down
4 changes: 0 additions & 4 deletions faker/providers/address/de/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# coding=utf-8

from __future__ import unicode_literals

from .. import Provider as AddressProvider


Expand Down
4 changes: 0 additions & 4 deletions faker/providers/address/de_AT/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# coding=utf-8

from __future__ import unicode_literals

from ..de import Provider as AddressProvider


Expand Down
4 changes: 0 additions & 4 deletions faker/providers/address/de_DE/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# coding=utf-8

from __future__ import unicode_literals

from ..de import Provider as AddressProvider


Expand Down
3 changes: 0 additions & 3 deletions faker/providers/address/el_GR/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding=utf-8
from __future__ import unicode_literals

from .. import Provider as AddressProvider


Expand Down
2 changes: 0 additions & 2 deletions faker/providers/address/en/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from .. import Provider as AddressProvider


Expand Down
2 changes: 0 additions & 2 deletions faker/providers/address/en_AU/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from ..en import Provider as AddressProvider


Expand Down
2 changes: 0 additions & 2 deletions faker/providers/address/en_CA/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import re

from ..en import Provider as AddressProvider
Expand Down
Loading

0 comments on commit 6e4a09e

Please sign in to comment.