Skip to content

Commit 9c4a1ca

Browse files
committed
Add support for blocking users
This also adds to our pre-commit configuration, upgrades how we build the package, and updates things with black. This supports blocking users from organizations and individual accounts.
1 parent 03191a4 commit 9c4a1ca

File tree

128 files changed

+883
-671
lines changed

Some content is hidden

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

128 files changed

+883
-671
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ tests/id_rsa
2525
t.py
2626
*.pem
2727
/.python-version
28+
/.tool-versions

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,31 @@ repos:
1313
- id: trailing-whitespace
1414
types: [text]
1515
stages: [commit, push, manual]
16+
- repo: https://github.com/asottile/reorder_python_imports
17+
rev: v2.6.0
18+
hooks:
19+
- id: reorder-python-imports
20+
args: [--application-directories, '.:src', --py36-plus]
21+
- repo: https://github.com/psf/black
22+
rev: 21.9b0
23+
hooks:
24+
- id: black
25+
- repo: https://github.com/asottile/pyupgrade
26+
rev: v2.23.3
27+
hooks:
28+
- id: pyupgrade
29+
args: [--py36-plus]
30+
#- repo: https://github.com/pre-commit/mirrors-mypy
31+
# rev: v0.910
32+
# hooks:
33+
# - id: mypy
34+
# exclude: ^(docs/|tests/)
35+
- repo: https://github.com/jorisroovers/gitlint
36+
rev: v0.16.0
37+
hooks:
38+
- id: gitlint
39+
- repo: https://github.com/asottile/setup-cfg-fmt
40+
rev: v1.18.0
41+
hooks:
42+
- id: setup-cfg-fmt
43+
args: [--min-py3-version, '3.6']

docs/source/conf.py

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Requests documentation build configuration file, created by
43
# sphinx-quickstart on Sun Feb 13 23:54:25 2011.
@@ -10,43 +9,43 @@
109
#
1110
# All configuration values have a default; values that are commented out
1211
# serve to show the default.
13-
14-
import sys, os
12+
import os
13+
import sys
1514

1615
# This environment variable makes decorators not decorate functions, so their
1716
# signatures in the generated documentation are still correct
18-
os.environ['GENERATING_DOCUMENTATION'] = "github3"
17+
os.environ["GENERATING_DOCUMENTATION"] = "github3"
1918

2019
# If extensions (or modules to document with autodoc) are in another directory,
2120
# add these directories to sys.path here. If the directory is relative to the
2221
# documentation root, use os.path.abspath to make it absolute, like shown here.
23-
sys.path.insert(0, os.path.abspath('..'))
22+
sys.path.insert(0, os.path.abspath(".."))
2423
import github3
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']
32+
extensions = ["sphinx.ext.autodoc"]
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 = 'github3.py'
49-
copyright = '2012-2021 - Ian Stapleton Cordasco'
47+
project = "github3.py"
48+
copyright = "2012-2021 - Ian Stapleton Cordasco"
5049

5150
# The version info for the project you're documenting, acts as replacement for
5251
# |version| and |release|, also used in various other places throughout the
@@ -59,181 +58,192 @@
5958

6059
# The language for content autogenerated by Sphinx. Refer to documentation
6160
# for a list of supported languages.
62-
#language = None
61+
# language = None
6362

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

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

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

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

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

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

8887
# The name of the Pygments (syntax highlighting) style to use.
8988
# pygments_style = 'flask_theme_support.FlaskyStyle'
9089

9190
# A list of ignored prefixes for module index sorting.
92-
#modindex_common_prefix = []
91+
# modindex_common_prefix = []
9392

9493

9594
# -- Options for HTML output ---------------------------------------------------
9695

9796
# The theme to use for HTML and HTML Help pages. See the documentation for
9897
# a list of builtin themes.
99-
#html_theme = 'nature'
98+
# html_theme = 'nature'
10099
html_theme = "sphinx_rtd_theme"
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 = '../img/gh3-logo-transparent.png'
118+
html_logo = "../img/gh3-logo-transparent.png"
120119

121120

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

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

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

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

140139
# Custom sidebar templates, maps document names to template names.
141140
# Custom sidebar templates, maps document names to template names.
142-
#html_sidebars = {}
141+
# html_sidebars = {}
143142

144143
# Additional templates that should be rendered to pages, maps page names to
145144
# template names.
146-
#html_additional_pages = {}
145+
# html_additional_pages = {}
147146

148147
# If false, no module index is generated.
149-
#html_domain_indices = True
148+
# html_domain_indices = True
150149

151150
# If false, no index is generated.
152-
#html_use_index = True
151+
# html_use_index = True
153152

154153
# If true, the index is split into individual pages for each letter.
155-
#html_split_index = False
154+
# html_split_index = False
156155

157156
# If true, links to the reST sources are added to the pages.
158-
#html_show_sourcelink = False
157+
# html_show_sourcelink = False
159158

160159
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
161-
#html_show_sphinx = False
160+
# html_show_sphinx = False
162161

163162
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
164-
#html_show_copyright = True
163+
# html_show_copyright = True
165164

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

171170
# This is the file name suffix for HTML files (e.g. ".xhtml").
172-
#html_file_suffix = None
171+
# html_file_suffix = None
173172

174173
# Output file base name for HTML help builder.
175-
htmlhelp_basename = 'github3.pydoc'
174+
htmlhelp_basename = "github3.pydoc"
176175

177176

178177
# -- Options for LaTeX output --------------------------------------------------
179178

180179
# The paper size ('letter' or 'a4').
181-
#latex_paper_size = 'letter'
180+
# latex_paper_size = 'letter'
182181

183182
# The font size ('10pt', '11pt' or '12pt').
184-
#latex_font_size = '10pt'
183+
# latex_font_size = '10pt'
185184

186185
# Grouping the document tree into LaTeX files. List of tuples
187186
# (source start file, target name, title, author, documentclass [howto/manual]).
188187
latex_documents = [
189-
('index', 'github3.py.tex', 'github3.py Documentation',
190-
'Ian Cordasco', 'manual'),
188+
(
189+
"index",
190+
"github3.py.tex",
191+
"github3.py Documentation",
192+
"Ian Cordasco",
193+
"manual",
194+
),
191195
]
192196

193197
# The name of an image file (relative to this directory) to place at the top of
194198
# the title page.
195-
#latex_logo = None
199+
# latex_logo = None
196200

197201
# For "manual" documents, if this is true, then toplevel headings are parts,
198202
# not chapters.
199-
#latex_use_parts = False
203+
# latex_use_parts = False
200204

201205
# If true, show page references after internal links.
202-
#latex_show_pagerefs = False
206+
# latex_show_pagerefs = False
203207

204208
# If true, show URL addresses after external links.
205-
#latex_show_urls = False
209+
# latex_show_urls = False
206210

207211
# Additional stuff for the LaTeX preamble.
208-
#latex_preamble = ''
212+
# latex_preamble = ''
209213

210214
# Documents to append as an appendix to all manuals.
211-
#latex_appendices = []
215+
# latex_appendices = []
212216

213217
# If false, no module index is generated.
214-
#latex_domain_indices = True
218+
# latex_domain_indices = True
215219

216220

217221
# -- Options for manual page output --------------------------------------------
218222

219223
# One entry per manual page. List of tuples
220224
# (source start file, name, description, authors, manual section).
221225
man_pages = [
222-
('index', 'github3.py', 'github3.py Documentation',
223-
['Ian Cordasco'], 1)
226+
("index", "github3.py", "github3.py Documentation", ["Ian Cordasco"], 1)
224227
]
225228

226229
# If true, show URL addresses after external links.
227-
#man_show_urls = False
230+
# man_show_urls = False
228231

229232
# -- Options for Texinfo output ------------------------------------------------
230233

231234
# Grouping the document tree into Texinfo files. List of tuples
232235
# (source start file, target name, title, author,
233236
# dir menu entry, description, category)
234237
texinfo_documents = [
235-
('index', 'github3.py', 'github3.py Documentation', 'Ian Cordasco',
236-
'github3.py', 'Wrapper for GitHub API v3', 'Miscellaneous'),
238+
(
239+
"index",
240+
"github3.py",
241+
"github3.py Documentation",
242+
"Ian Cordasco",
243+
"github3.py",
244+
"Wrapper for GitHub API v3",
245+
"Miscellaneous",
246+
),
237247
]
238248

239249
# Documents to append as an appendix to all manuals.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import webbrowser
21
import tempfile
2+
import webbrowser
3+
34
import github3
45

56
template = """<html><head></head><body>{0}</body></html>"""
67

7-
i = github3.issue('kennethreitz', 'requests', 868)
8+
i = github3.issue("kennethreitz", "requests", 868)
89

910
with tempfile.NamedTemporaryFile() as tmpfd:
1011
tmpfd.write(template.format(i.body_html))
11-
webbrowser.open('file://' + tmpfd.name)
12+
webbrowser.open("file://" + tmpfd.name)
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
import github3
21
import logging
32

3+
import github3
4+
45
# Set up a file to have all the logs written to
5-
file_handler = logging.FileHandler('github_script.log')
6+
file_handler = logging.FileHandler("github_script.log")
67

78
# Send the logs to stderr as well
89
stream_handler = logging.StreamHandler()
910

1011
# Format the log output and include the log level's name and the time it was
1112
# generated
12-
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
13+
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
1314

1415
# Use that Formatter on both handlers
1516
file_handler.setFormatter(formatter)
1617
stream_handler.setFormatter(formatter)
1718

1819
# Get the logger used by github3.py internally by referencing its name
1920
# directly
20-
logger = logging.getLogger('github3')
21+
logger = logging.getLogger("github3")
2122
# Add the handlers to it
2223
logger.addHandler(file_handler)
2324
logger.addHandler(stream_handler)
2425
# Set the level which determines what you see
2526
logger.setLevel(logging.DEBUG)
2627

2728
# Make a library call and see the information posted
28-
r = github3.repository('sigmavirus24', 'github3.py')
29-
print('{0} - {0.html_url}'.format(r))
29+
r = github3.repository("sigmavirus24", "github3.py")
30+
print("{0} - {0.html_url}".format(r))

0 commit comments

Comments
 (0)