Skip to content

Commit 72eb55b

Browse files
authored
Drop support for EOL python 2 (#105)
* drop support for EOL pythons (python 2.7, 3.5) * test with py3.10 * pre-commit autoupdate * add pyupgrade to pre-commit hooks
1 parent 1601cb7 commit 72eb55b

File tree

13 files changed

+135
-157
lines changed

13 files changed

+135
-157
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ repos:
66
hooks:
77
- id: black
88
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v3.2.0
9+
rev: v3.4.0
1010
hooks:
1111
- id: trailing-whitespace
1212
- id: end-of-file-fixer
1313
- id: check-yaml
1414
- id: check-added-large-files
15+
- repo: https://github.com/asottile/pyupgrade
16+
rev: v2.7.2
17+
hooks:
18+
- id: pyupgrade
19+
args: [--py36-plus]

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
language: python
33
dist: bionic
44
python:
5-
- "2.7"
65
- "3.6"
76
- "3.7"
87
- "3.8"
98
- "3.9"
9+
- "3.10-dev"
1010

1111
install:
1212
- pip install tox tox-travis

docs/conf.py

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Sphinx config."""
2-
# -*- coding: utf-8 -*-
32
#
43
# pytest-factoryboy documentation build configuration file, created by
54
# sphinx-quickstart on Sun Apr 7 21:07:56 2013.
@@ -19,35 +18,35 @@
1918
import sys
2019
import os
2120

22-
sys.path.insert(0, os.path.abspath('..'))
21+
sys.path.insert(0, os.path.abspath(".."))
2322

2423
import pytest_factoryboy
2524

2625
# -- General configuration -----------------------------------------------------
2726

2827
# If your documentation needs a minimal Sphinx version, state it here.
29-
#needs_sphinx = '1.0'
28+
# needs_sphinx = '1.0'
3029

3130
# Add any Sphinx extension module names here, as strings. They can be extensions
3231
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
33-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
32+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
3433

3534
# Add any paths that contain templates here, relative to this directory.
36-
templates_path = ['_templates']
35+
templates_path = ["_templates"]
3736

3837
# The suffix of source filenames.
39-
source_suffix = '.rst'
38+
source_suffix = ".rst"
4039

4140
# The encoding of source files.
42-
#source_encoding = 'utf-8-sig'
41+
# source_encoding = 'utf-8-sig'
4342

4443
# The master toctree document.
45-
master_doc = 'index'
44+
master_doc = "index"
4645

4746
# General information about the project.
48-
project = u'pytest-factoryboy'
49-
AUTHOR = 'Oleg Pidsadnyi, Anatoly Bubenkov and others'
50-
copyright = u'2015, ' + AUTHOR
47+
project = "pytest-factoryboy"
48+
AUTHOR = "Oleg Pidsadnyi, Anatoly Bubenkov and others"
49+
copyright = "2015, " + AUTHOR
5150

5251
# The version info for the project you're documenting, acts as replacement for
5352
# |version| and |release|, also used in various other places throughout the
@@ -60,170 +59,165 @@
6059

6160
# The language for content autogenerated by Sphinx. Refer to documentation
6261
# for a list of supported languages.
63-
#language = None
62+
# language = None
6463

6564
# There are two options for replacing |today|: either, you set today to some
6665
# non-false value, then it is used:
67-
#today = ''
66+
# today = ''
6867
# Else, today_fmt is used as the format for a strftime call.
69-
#today_fmt = '%B %d, %Y'
68+
# today_fmt = '%B %d, %Y'
7069

7170
# List of patterns, relative to source directory, that match files and
7271
# directories to ignore when looking for source files.
73-
exclude_patterns = ['_build']
72+
exclude_patterns = ["_build"]
7473

7574
# The reST default role (used for this markup: `text`) to use for all documents.
76-
#default_role = None
75+
# default_role = None
7776

7877
# If true, '()' will be appended to :func: etc. cross-reference text.
79-
#add_function_parentheses = True
78+
# add_function_parentheses = True
8079

8180
# If true, the current module name will be prepended to all description
8281
# unit titles (such as .. function::).
83-
#add_module_names = True
82+
# add_module_names = True
8483

8584
# If true, sectionauthor and moduleauthor directives will be shown in the
8685
# output. They are ignored by default.
87-
#show_authors = False
86+
# show_authors = False
8887

8988
# The name of the Pygments (syntax highlighting) style to use.
90-
pygments_style = 'sphinx'
89+
pygments_style = "sphinx"
9190

9291
# A list of ignored prefixes for module index sorting.
93-
#modindex_common_prefix = []
92+
# modindex_common_prefix = []
9493

9594

9695
# -- Options for HTML output ---------------------------------------------------
9796

9897
# The theme to use for HTML and HTML Help pages. See the documentation for
9998
# a list of builtin themes.
100-
html_theme = 'default'
99+
html_theme = "default"
101100

102101
# Theme options are theme-specific and customize the look and feel of a theme
103102
# further. For a list of options available for each theme, see the
104103
# documentation.
105-
#html_theme_options = {}
104+
# html_theme_options = {}
106105

107106
# Add any paths that contain custom themes here, relative to this directory.
108-
#html_theme_path = []
107+
# html_theme_path = []
109108

110109
# The name for this set of Sphinx documents. If None, it defaults to
111110
# "<project> v<release> documentation".
112-
#html_title = None
111+
# html_title = None
113112

114113
# A shorter title for the navigation bar. Default is the same as html_title.
115-
#html_short_title = None
114+
# html_short_title = None
116115

117116
# The name of an image file (relative to this directory) to place at the top
118117
# of the sidebar.
119-
#html_logo = None
118+
# html_logo = None
120119

121120
# The name of an image file (within the static path) to use as favicon of the
122121
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
123122
# pixels large.
124-
#html_favicon = None
123+
# html_favicon = None
125124

126125
# Add any paths that contain custom static files (such as style sheets) here,
127126
# relative to this directory. They are copied after the builtin static files,
128127
# so a file named "default.css" will overwrite the builtin "default.css".
129-
html_static_path = ['_static']
128+
html_static_path = ["_static"]
130129

131130
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
132131
# using the given strftime format.
133-
#html_last_updated_fmt = '%b %d, %Y'
132+
# html_last_updated_fmt = '%b %d, %Y'
134133

135134
# If true, SmartyPants will be used to convert quotes and dashes to
136135
# typographically correct entities.
137-
#html_use_smartypants = True
136+
# html_use_smartypants = True
138137

139138
# Custom sidebar templates, maps document names to template names.
140-
#html_sidebars = {}
139+
# html_sidebars = {}
141140

142141
# Additional templates that should be rendered to pages, maps page names to
143142
# template names.
144-
#html_additional_pages = {}
143+
# html_additional_pages = {}
145144

146145
# If false, no module index is generated.
147-
#html_domain_indices = True
146+
# html_domain_indices = True
148147

149148
# If false, no index is generated.
150-
#html_use_index = True
149+
# html_use_index = True
151150

152151
# If true, the index is split into individual pages for each letter.
153-
#html_split_index = False
152+
# html_split_index = False
154153

155154
# If true, links to the reST sources are added to the pages.
156-
#html_show_sourcelink = True
155+
# html_show_sourcelink = True
157156

158157
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
159-
#html_show_sphinx = True
158+
# html_show_sphinx = True
160159

161160
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
162-
#html_show_copyright = True
161+
# html_show_copyright = True
163162

164163
# If true, an OpenSearch description file will be output, and all pages will
165164
# contain a <link> tag referring to it. The value of this option must be the
166165
# base URL from which the finished HTML is served.
167-
#html_use_opensearch = ''
166+
# html_use_opensearch = ''
168167

169168
# This is the file name suffix for HTML files (e.g. ".xhtml").
170-
#html_file_suffix = None
169+
# html_file_suffix = None
171170

172171
# Output file base name for HTML help builder.
173-
htmlhelp_basename = 'pytest-factoryboy-doc'
172+
htmlhelp_basename = "pytest-factoryboy-doc"
174173

175174

176175
# -- Options for LaTeX output --------------------------------------------------
177176

178177
latex_elements = {
179178
# The paper size ('letterpaper' or 'a4paper').
180179
#'papersize': 'letterpaper',
181-
182180
# The font size ('10pt', '11pt' or '12pt').
183181
#'pointsize': '10pt',
184-
185182
# Additional stuff for the LaTeX preamble.
186183
#'preamble': '',
187184
}
188185

189186
# Grouping the document tree into LaTeX files. List of tuples
190187
# (source start file, target name, title, author, documentclass [howto/manual]).
191188
latex_documents = [
192-
('index', 'pytest-factoryboy.tex', u'pytest-factoryboy Documentation', AUTHOR, 'manual'),
189+
("index", "pytest-factoryboy.tex", "pytest-factoryboy Documentation", AUTHOR, "manual"),
193190
]
194191

195192
# The name of an image file (relative to this directory) to place at the top of
196193
# the title page.
197-
#latex_logo = None
194+
# latex_logo = None
198195

199196
# For "manual" documents, if this is true, then toplevel headings are parts,
200197
# not chapters.
201-
#latex_use_parts = False
198+
# latex_use_parts = False
202199

203200
# If true, show page references after internal links.
204-
#latex_show_pagerefs = False
201+
# latex_show_pagerefs = False
205202

206203
# If true, show URL addresses after external links.
207-
#latex_show_urls = False
204+
# latex_show_urls = False
208205

209206
# Documents to append as an appendix to all manuals.
210-
#latex_appendices = []
207+
# latex_appendices = []
211208

212209
# If false, no module index is generated.
213-
#latex_domain_indices = True
210+
# latex_domain_indices = True
214211

215212

216213
# -- Options for manual page output --------------------------------------------
217214

218215
# One entry per manual page. List of tuples
219216
# (source start file, name, description, authors, manual section).
220-
man_pages = [
221-
('index', 'pytest-factoryboy', u'pytest-factoryboy Documentation',
222-
[AUTHOR], 1)
223-
]
217+
man_pages = [("index", "pytest-factoryboy", "pytest-factoryboy Documentation", [AUTHOR], 1)]
224218

225219
# If true, show URL addresses after external links.
226-
#man_show_urls = False
220+
# man_show_urls = False
227221

228222

229223
# -- Options for Texinfo output ------------------------------------------------
@@ -232,16 +226,22 @@
232226
# (source start file, target name, title, author,
233227
# dir menu entry, description, category)
234228
texinfo_documents = [
235-
('index', 'pytest-factoryboy', u'pytest-factoryboy Documentation',
236-
AUTHOR, 'pytest-factoryboy', 'factory_boy integration the pytest runner.',
237-
'Miscellaneous'),
229+
(
230+
"index",
231+
"pytest-factoryboy",
232+
"pytest-factoryboy Documentation",
233+
AUTHOR,
234+
"pytest-factoryboy",
235+
"factory_boy integration the pytest runner.",
236+
"Miscellaneous",
237+
),
238238
]
239239

240240
# Documents to append as an appendix to all manuals.
241-
#texinfo_appendices = []
241+
# texinfo_appendices = []
242242

243243
# If false, no module index is generated.
244-
#texinfo_domain_indices = True
244+
# texinfo_domain_indices = True
245245

246246
# How to display URL addresses: 'footnote', 'no', or 'inline'.
247-
#texinfo_show_urls = 'footnote'
247+
# texinfo_show_urls = 'footnote'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[tool.black]
22
line-length = 120
3-
target-version = ['py27', 'py36', 'py37', 'py38']
3+
target-version = ['py36']

pytest_factoryboy/fixture.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
import inflection
1010
import pytest
1111

12-
from inspect import getmodule
13-
14-
if sys.version_info > (3, 0):
15-
from inspect import signature
16-
else:
17-
from funcsigs import signature
12+
from inspect import getmodule, signature
1813

1914
SEPARATOR = "__"
2015

@@ -198,11 +193,11 @@ def model_fixture(request, factory_name):
198193
class Factory(factory_class):
199194
pass
200195

201-
Factory._meta.base_declarations = dict(
202-
(k, v)
196+
Factory._meta.base_declarations = {
197+
k: v
203198
for k, v in Factory._meta.base_declarations.items()
204199
if not isinstance(v, factory.declarations.PostGenerationDeclaration)
205-
)
200+
}
206201
Factory._meta.post_declarations = factory.builder.DeclarationSet()
207202

208203
kwargs = {}
@@ -329,7 +324,7 @@ def get_caller_module(depth=2):
329324
return module
330325

331326

332-
class LazyFixture(object):
327+
class LazyFixture:
333328
"""Lazy fixture."""
334329

335330
def __init__(self, fixture):
@@ -351,7 +346,7 @@ def evaluate(self, request):
351346
:return: evaluated fixture.
352347
"""
353348
if callable(self.fixture):
354-
kwargs = dict((arg, request.getfixturevalue(arg)) for arg in self.args)
349+
kwargs = {arg: request.getfixturevalue(arg) for arg in self.args}
355350
return self.fixture(**kwargs)
356351
else:
357352
return request.getfixturevalue(self.fixture)

pytest_factoryboy/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class CycleDetected(Exception):
88
pass
99

1010

11-
class Request(object):
11+
class Request:
1212
"""PyTest FactoryBoy request."""
1313

1414
def __init__(self):
@@ -30,7 +30,7 @@ def get_deps(self, request, fixture, deps=None):
3030
request = request.getfixturevalue("request")
3131

3232
if deps is None:
33-
deps = set([fixture])
33+
deps = {fixture}
3434
if fixture == "request":
3535
return deps
3636

0 commit comments

Comments
 (0)