Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: blacken #375

Merged
merged 2 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
ignore = E203, E266, E501, W503
exclude =
# Standard linting exemptions.
__pycache__,
.git,
*.pyc,
conf.py
125 changes: 62 additions & 63 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,40 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinx_docstring_typing'
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx_docstring_typing",
]

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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
#
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'google-auth'
copyright = '2016, Google, Inc.'
author = 'Google, Inc.'
project = "google-auth"
copyright = "2016, Google, Inc."
author = "Google, Inc."

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = pkg_resources.get_distribution('google-auth').version
version = pkg_resources.get_distribution("google-auth").version
# The full version, including alpha/beta/rc tags.
release = version

Expand All @@ -89,7 +89,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -111,7 +111,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -128,21 +128,21 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'description': 'Google Auth Library for Python',
'github_user': 'GoogleCloudPlatform',
'github_repo': 'google-auth-library-python',
'github_banner': True,
'travis_button': True,
'font_family': "'Roboto', Georgia, sans",
'head_font_family': "'Roboto', Georgia, serif",
'code_font_family': "'Roboto Mono', 'Consolas', monospace",
"description": "Google Auth Library for Python",
"github_user": "GoogleCloudPlatform",
"github_repo": "google-auth-library-python",
"github_banner": True,
"travis_button": True,
"font_family": "'Roboto', Georgia, sans",
"head_font_family": "'Roboto', Georgia, serif",
"code_font_family": "'Roboto Mono', 'Consolas', monospace",
}

# Add any paths that contain custom themes here, relative to this directory.
Expand Down Expand Up @@ -171,7 +171,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand All @@ -194,12 +194,7 @@
#

html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html',
'searchbox.html',
]
"**": ["about.html", "navigation.html", "relations.html", "searchbox.html"]
}

# Additional templates that should be rendered to pages, maps page names to
Expand Down Expand Up @@ -259,34 +254,36 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'google-authdoc'
htmlhelp_basename = "google-authdoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'google-auth.tex', 'google-auth Documentation',
'Google, Inc.', 'manual'),
(
master_doc,
"google-auth.tex",
"google-auth Documentation",
"Google, Inc.",
"manual",
)
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -326,10 +323,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'google-auth', 'google-auth Documentation',
[author], 1)
]
man_pages = [(master_doc, "google-auth", "google-auth Documentation", [author], 1)]

# If true, show URL addresses after external links.
#
Expand All @@ -342,9 +336,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'google-auth', 'google-auth Documentation',
author, 'google-auth', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"google-auth",
"google-auth Documentation",
author,
"google-auth",
"One line description of project.",
"Miscellaneous",
)
]

# Documents to append as an appendix to all manuals.
Expand All @@ -366,14 +366,13 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3.5', None),
'urllib3': ('https://urllib3.readthedocs.io/en/stable', None),
'requests': ('http://docs.python-requests.org/en/stable', None),
'requests-oauthlib': (
'http://requests-oauthlib.readthedocs.io/en/stable', None),
"python": ("https://docs.python.org/3.5", None),
"urllib3": ("https://urllib3.readthedocs.io/en/stable", None),
"requests": ("http://docs.python-requests.org/en/stable", None),
"requests-oauthlib": ("http://requests-oauthlib.readthedocs.io/en/stable", None),
}

# Autodoc config
autoclass_content = 'both'
autodoc_member_order = 'bysource'
autodoc_mock_imports = ['grpc']
autoclass_content = "both"
autodoc_member_order = "bysource"
autodoc_mock_imports = ["grpc"]
2 changes: 2 additions & 0 deletions google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

try:
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
4 changes: 1 addition & 3 deletions google/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
from google.auth._default import default


__all__ = [
'default',
]
__all__ = ["default"]


# Set default logging handler to avoid "No handler found" warnings.
Expand Down
42 changes: 20 additions & 22 deletions google/auth/_cloud_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@


# The ~/.config subdirectory containing gcloud credentials.
_CONFIG_DIRECTORY = 'gcloud'
_CONFIG_DIRECTORY = "gcloud"
# Windows systems store config at %APPDATA%\gcloud
_WINDOWS_CONFIG_ROOT_ENV_VAR = 'APPDATA'
_WINDOWS_CONFIG_ROOT_ENV_VAR = "APPDATA"
# The name of the file in the Cloud SDK config that contains default
# credentials.
_CREDENTIALS_FILENAME = 'application_default_credentials.json'
_CREDENTIALS_FILENAME = "application_default_credentials.json"
# The name of the Cloud SDK shell script
_CLOUD_SDK_POSIX_COMMAND = 'gcloud'
_CLOUD_SDK_WINDOWS_COMMAND = 'gcloud.cmd'
_CLOUD_SDK_POSIX_COMMAND = "gcloud"
_CLOUD_SDK_WINDOWS_COMMAND = "gcloud.cmd"
# The command to get the Cloud SDK configuration
_CLOUD_SDK_CONFIG_COMMAND = ('config', 'config-helper', '--format', 'json')
_CLOUD_SDK_CONFIG_COMMAND = ("config", "config-helper", "--format", "json")
# Cloud SDK's application-default client ID
CLOUD_SDK_CLIENT_ID = (
'764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com')
"764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com"
)


def get_config_path():
Expand All @@ -52,21 +53,19 @@ def get_config_path():
pass

# Non-windows systems store this at ~/.config/gcloud
if os.name != 'nt':
return os.path.join(
os.path.expanduser('~'), '.config', _CONFIG_DIRECTORY)
if os.name != "nt":
return os.path.join(os.path.expanduser("~"), ".config", _CONFIG_DIRECTORY)
# Windows systems store config at %APPDATA%\gcloud
else:
try:
return os.path.join(
os.environ[_WINDOWS_CONFIG_ROOT_ENV_VAR],
_CONFIG_DIRECTORY)
os.environ[_WINDOWS_CONFIG_ROOT_ENV_VAR], _CONFIG_DIRECTORY
)
except KeyError:
# This should never happen unless someone is really
# messing with things, but we'll cover the case anyway.
drive = os.environ.get('SystemDrive', 'C:')
return os.path.join(
drive, '\\', _CONFIG_DIRECTORY)
drive = os.environ.get("SystemDrive", "C:")
return os.path.join(drive, "\\", _CONFIG_DIRECTORY)


def get_application_default_credentials_path():
Expand All @@ -93,8 +92,7 @@ def load_authorized_user_credentials(info):
Raises:
ValueError: if the info is in the wrong format or missing data.
"""
return google.oauth2.credentials.Credentials.from_authorized_user_info(
info)
return google.oauth2.credentials.Credentials.from_authorized_user_info(info)


def get_project_id():
Expand All @@ -103,24 +101,24 @@ def get_project_id():
Returns:
Optional[str]: The project ID.
"""
if os.name == 'nt':
if os.name == "nt":
command = _CLOUD_SDK_WINDOWS_COMMAND
else:
command = _CLOUD_SDK_POSIX_COMMAND

try:
output = subprocess.check_output(
(command,) + _CLOUD_SDK_CONFIG_COMMAND,
stderr=subprocess.STDOUT)
(command,) + _CLOUD_SDK_CONFIG_COMMAND, stderr=subprocess.STDOUT
)
except (subprocess.CalledProcessError, OSError, IOError):
return None

try:
configuration = json.loads(output.decode('utf-8'))
configuration = json.loads(output.decode("utf-8"))
except ValueError:
return None

try:
return configuration['configuration']['properties']['core']['project']
return configuration["configuration"]["properties"]["core"]["project"]
except KeyError:
return None
Loading