Skip to content

Commit c80b2b6

Browse files
Merge pull request #368 from singingwolfboy/black
Require code formatting with `black`
2 parents 91c27e9 + 58bb5b4 commit c80b2b6

22 files changed

+1024
-778
lines changed

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ script:
1818
- coverage run --source=requests_oauthlib -m unittest discover
1919
after_success:
2020
- coveralls
21+
22+
matrix:
23+
include:
24+
- name: "Black"
25+
python: 3.7
26+
install: travis_retry pip install black
27+
script: black --check .
28+
after_success: skip

docs/conf.py

+84-70
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@
1616
# If extensions (or modules to document with autodoc) are in another directory,
1717
# add these directories to sys.path here. If the directory is relative to the
1818
# documentation root, use os.path.abspath to make it absolute, like shown here.
19-
sys.path.insert(0, os.path.abspath('..'))
19+
sys.path.insert(0, os.path.abspath(".."))
2020
from requests_oauthlib import __version__
2121

2222
# -- General configuration -----------------------------------------------------
2323

2424
# If your documentation needs a minimal Sphinx version, state it here.
25-
#needs_sphinx = '1.0'
25+
# needs_sphinx = '1.0'
2626

2727
# Add any Sphinx extension module names here, as strings. They can be extensions
2828
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
29-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']
29+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx"]
3030

3131
# Add any paths that contain templates here, relative to this directory.
32-
templates_path = ['_templates']
32+
templates_path = ["_templates"]
3333

3434
# The suffix of source filenames.
35-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3636

3737
# The encoding of source files.
38-
#source_encoding = 'utf-8-sig'
38+
# source_encoding = 'utf-8-sig'
3939

4040
# The master toctree document.
41-
master_doc = 'index'
41+
master_doc = "index"
4242

4343
# General information about the project.
44-
project = u'Requests-OAuthlib'
45-
copyright = u'2014, Kenneth Reitz'
44+
project = u"Requests-OAuthlib"
45+
copyright = u"2014, Kenneth Reitz"
4646

4747
# The version info for the project you're documenting, acts as replacement for
4848
# |version| and |release|, also used in various other places throughout the
@@ -55,174 +55,182 @@
5555

5656
# The language for content autogenerated by Sphinx. Refer to documentation
5757
# for a list of supported languages.
58-
#language = None
58+
# language = None
5959

6060
# There are two options for replacing |today|: either, you set today to some
6161
# non-false value, then it is used:
62-
#today = ''
62+
# today = ''
6363
# Else, today_fmt is used as the format for a strftime call.
64-
#today_fmt = '%B %d, %Y'
64+
# today_fmt = '%B %d, %Y'
6565

6666
# List of patterns, relative to source directory, that match files and
6767
# directories to ignore when looking for source files.
68-
exclude_patterns = ['_build']
68+
exclude_patterns = ["_build"]
6969

7070
# The reST default role (used for this markup: `text`) to use for all documents.
71-
#default_role = None
71+
# default_role = None
7272

7373
# If true, '()' will be appended to :func: etc. cross-reference text.
74-
#add_function_parentheses = True
74+
# add_function_parentheses = True
7575

7676
# If true, the current module name will be prepended to all description
7777
# unit titles (such as .. function::).
78-
#add_module_names = True
78+
# add_module_names = True
7979

8080
# If true, sectionauthor and moduleauthor directives will be shown in the
8181
# output. They are ignored by default.
82-
#show_authors = False
82+
# show_authors = False
8383

8484
# The name of the Pygments (syntax highlighting) style to use.
85-
pygments_style = 'sphinx'
85+
pygments_style = "sphinx"
8686

8787
# A list of ignored prefixes for module index sorting.
88-
#modindex_common_prefix = []
88+
# modindex_common_prefix = []
8989

9090
# If true, keep warnings as "system message" paragraphs in the built documents.
91-
#keep_warnings = False
91+
# keep_warnings = False
9292

9393

9494
# -- Options for HTML output ---------------------------------------------------
9595

9696
# The theme to use for HTML and HTML Help pages. See the documentation for
9797
# a list of builtin themes.
98-
html_theme = 'default'
98+
html_theme = "default"
9999

100100
# Theme options are theme-specific and customize the look and feel of a theme
101101
# further. For a list of options available for each theme, see the
102102
# documentation.
103-
#html_theme_options = {}
103+
# html_theme_options = {}
104104

105105
# Add any paths that contain custom themes here, relative to this directory.
106-
#html_theme_path = []
106+
# html_theme_path = []
107107

108108
# The name for this set of Sphinx documents. If None, it defaults to
109109
# "<project> v<release> documentation".
110-
#html_title = None
110+
# html_title = None
111111

112112
# A shorter title for the navigation bar. Default is the same as html_title.
113-
#html_short_title = None
113+
# html_short_title = None
114114

115115
# The name of an image file (relative to this directory) to place at the top
116116
# of the sidebar.
117-
#html_logo = None
117+
# html_logo = None
118118

119119
# The name of an image file (within the static path) to use as favicon of the
120120
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
121121
# pixels large.
122-
#html_favicon = None
122+
# html_favicon = None
123123

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

129129
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
130130
# using the given strftime format.
131-
#html_last_updated_fmt = '%b %d, %Y'
131+
# html_last_updated_fmt = '%b %d, %Y'
132132

133133
# If true, SmartyPants will be used to convert quotes and dashes to
134134
# typographically correct entities.
135-
#html_use_smartypants = True
135+
# html_use_smartypants = True
136136

137137
# Custom sidebar templates, maps document names to template names.
138-
#html_sidebars = {}
138+
# html_sidebars = {}
139139

140140
# Additional templates that should be rendered to pages, maps page names to
141141
# template names.
142-
#html_additional_pages = {}
142+
# html_additional_pages = {}
143143

144144
# If false, no module index is generated.
145-
#html_domain_indices = True
145+
# html_domain_indices = True
146146

147147
# If false, no index is generated.
148-
#html_use_index = True
148+
# html_use_index = True
149149

150150
# If true, the index is split into individual pages for each letter.
151-
#html_split_index = False
151+
# html_split_index = False
152152

153153
# If true, links to the reST sources are added to the pages.
154-
#html_show_sourcelink = True
154+
# html_show_sourcelink = True
155155

156156
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
157-
#html_show_sphinx = True
157+
# html_show_sphinx = True
158158

159159
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
160-
#html_show_copyright = True
160+
# html_show_copyright = True
161161

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

167167
# This is the file name suffix for HTML files (e.g. ".xhtml").
168-
#html_file_suffix = None
168+
# html_file_suffix = None
169169

170170
# Output file base name for HTML help builder.
171-
htmlhelp_basename = 'Requests-OAuthlibdoc'
171+
htmlhelp_basename = "Requests-OAuthlibdoc"
172172

173173

174174
# -- Options for LaTeX output --------------------------------------------------
175175

176176
latex_elements = {
177-
# The paper size ('letterpaper' or 'a4paper').
178-
#'papersize': 'letterpaper',
179-
180-
# The font size ('10pt', '11pt' or '12pt').
181-
#'pointsize': '10pt',
182-
183-
# Additional stuff for the LaTeX preamble.
184-
#'preamble': '',
177+
# The paper size ('letterpaper' or 'a4paper').
178+
#'papersize': 'letterpaper',
179+
# The font size ('10pt', '11pt' or '12pt').
180+
#'pointsize': '10pt',
181+
# Additional stuff for the LaTeX preamble.
182+
#'preamble': '',
185183
}
186184

187185
# Grouping the document tree into LaTeX files. List of tuples
188186
# (source start file, target name, title, author, documentclass [howto/manual]).
189187
latex_documents = [
190-
('index', 'Requests-OAuthlib.tex', u'Requests-OAuthlib Documentation',
191-
u'Requests-OAuthlib Contributors', 'manual'),
188+
(
189+
"index",
190+
"Requests-OAuthlib.tex",
191+
u"Requests-OAuthlib Documentation",
192+
u"Requests-OAuthlib Contributors",
193+
"manual",
194+
)
192195
]
193196

194197
# The name of an image file (relative to this directory) to place at the top of
195198
# the title page.
196-
#latex_logo = None
199+
# latex_logo = None
197200

198201
# For "manual" documents, if this is true, then toplevel headings are parts,
199202
# not chapters.
200-
#latex_use_parts = False
203+
# latex_use_parts = False
201204

202205
# If true, show page references after internal links.
203-
#latex_show_pagerefs = False
206+
# latex_show_pagerefs = False
204207

205208
# If true, show URL addresses after external links.
206-
#latex_show_urls = False
209+
# latex_show_urls = False
207210

208211
# Documents to append as an appendix to all manuals.
209-
#latex_appendices = []
212+
# latex_appendices = []
210213

211214
# If false, no module index is generated.
212-
#latex_domain_indices = True
215+
# latex_domain_indices = True
213216

214217

215218
# -- Options for manual page output --------------------------------------------
216219

217220
# One entry per manual page. List of tuples
218221
# (source start file, name, description, authors, manual section).
219222
man_pages = [
220-
('index', 'requests-oauthlib', u'Requests-OAuthlib Documentation',
221-
[u'Requests-OAuthlib Contributors'], 1)
223+
(
224+
"index",
225+
"requests-oauthlib",
226+
u"Requests-OAuthlib Documentation",
227+
[u"Requests-OAuthlib Contributors"],
228+
1,
229+
)
222230
]
223231

224232
# If true, show URL addresses after external links.
225-
#man_show_urls = False
233+
# man_show_urls = False
226234

227235

228236
# -- Options for Texinfo output ------------------------------------------------
@@ -231,27 +239,33 @@
231239
# (source start file, target name, title, author,
232240
# dir menu entry, description, category)
233241
texinfo_documents = [
234-
('index', 'Requests-OAuthlib', u'Requests-OAuthlib Documentation',
235-
u'Requests-OAuthlib Contributors', 'Requests-OAuthlib', 'One line description of project.',
236-
'Miscellaneous'),
242+
(
243+
"index",
244+
"Requests-OAuthlib",
245+
u"Requests-OAuthlib Documentation",
246+
u"Requests-OAuthlib Contributors",
247+
"Requests-OAuthlib",
248+
"One line description of project.",
249+
"Miscellaneous",
250+
)
237251
]
238252

239253
# Documents to append as an appendix to all manuals.
240-
#texinfo_appendices = []
254+
# texinfo_appendices = []
241255

242256
# If false, no module index is generated.
243-
#texinfo_domain_indices = True
257+
# texinfo_domain_indices = True
244258

245259
# How to display URL addresses: 'footnote', 'no', or 'inline'.
246-
#texinfo_show_urls = 'footnote'
260+
# texinfo_show_urls = 'footnote'
247261

248262
# If true, do not generate a @detailmenu in the "Top" node's menu.
249-
#texinfo_no_detailmenu = False
263+
# texinfo_no_detailmenu = False
250264

251265

252266
# Example configuration for intersphinx: refer to the Python standard library.
253267
intersphinx_mapping = {
254-
'python': ('https://python.readthedocs.io/en/latest/', None),
255-
'requests': ('https://requests.readthedocs.io/en/latest/', None),
256-
'oauthlib': ('https://oauthlib.readthedocs.io/en/latest/', None),
268+
"python": ("https://python.readthedocs.io/en/latest/", None),
269+
"requests": ("https://requests.readthedocs.io/en/latest/", None),
270+
"oauthlib": ("https://oauthlib.readthedocs.io/en/latest/", None),
257271
}

requests_oauthlib/__init__.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
from .oauth2_auth import OAuth2
66
from .oauth2_session import OAuth2Session, TokenUpdated
77

8-
__version__ = '1.2.0'
8+
__version__ = "1.2.0"
99

1010
import requests
11-
if requests.__version__ < '2.0.0':
12-
msg = ('You are using requests version %s, which is older than '
13-
'requests-oauthlib expects, please upgrade to 2.0.0 or later.')
11+
12+
if requests.__version__ < "2.0.0":
13+
msg = (
14+
"You are using requests version %s, which is older than "
15+
"requests-oauthlib expects, please upgrade to 2.0.0 or later."
16+
)
1417
raise Warning(msg % requests.__version__)
1518

16-
logging.getLogger('requests_oauthlib').addHandler(logging.NullHandler())
19+
logging.getLogger("requests_oauthlib").addHandler(logging.NullHandler())

requests_oauthlib/compliance_fixes/douban.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55

66
def douban_compliance_fix(session):
7-
87
def fix_token_type(r):
98
token = json.loads(r.text)
10-
token.setdefault('token_type', 'Bearer')
9+
token.setdefault("token_type", "Bearer")
1110
fixed_token = json.dumps(token)
12-
r._content = to_unicode(fixed_token).encode('utf-8')
11+
r._content = to_unicode(fixed_token).encode("utf-8")
1312
return r
1413

15-
session._client_default_token_placement = 'query'
16-
session.register_compliance_hook('access_token_response', fix_token_type)
14+
session._client_default_token_placement = "query"
15+
session.register_compliance_hook("access_token_response", fix_token_type)
1716

1817
return session

0 commit comments

Comments
 (0)