Skip to content

Commit

Permalink
Sceptregh-1276: Reformatted with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
dboitnot committed Dec 23, 2022
1 parent ac0c646 commit 40e4d80
Show file tree
Hide file tree
Showing 102 changed files with 3,869 additions and 3,916 deletions.
8 changes: 4 additions & 4 deletions .circleci/documentation-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def main():
if item.is_dir() and VERSION_REGEX.match(item.name)
),
reverse=True,
key=attrgetter("name")
key=attrgetter("name"),
)

active_versions = (
["latest", "dev"]
+ [item.name for item in documentation_directories[:NUMBER_OF_VERSIONS_TO_KEEP]]
+ KEEP_VERSIONS
["latest", "dev"]
+ [item.name for item in documentation_directories[:NUMBER_OF_VERSIONS_TO_KEEP]]
+ KEEP_VERSIONS
)
versions_to_remove = (
item.path
Expand Down
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ max-complexity = 12
per-file-ignores =
docs/_api/conf.py: E265
integration-tests/steps/*: E501,F811,F403,F405
extend-ignore = E203
max-line-length = 120
85 changes: 41 additions & 44 deletions docs/_source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..' + os.path.sep + '..'))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".." + os.path.sep + ".."))
import sceptre # noqa

# The short X.Y version
version = sceptre.__version__
# The full version, including alpha/beta/rc tags
release = version

project = 'Sceptre'
copyright = '2018, Cloudreach'
project = "Sceptre"
copyright = "2018, Cloudreach"
author = sceptre.__author__

# -- General configuration ---------------------------------------------------
Expand All @@ -41,34 +41,34 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx_autodoc_typehints',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx_click.ext',
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx_click.ext",
]

# 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 master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set 'language' from the command line for these cases.
language = 'en'
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -83,7 +83,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# 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
Expand All @@ -110,7 +110,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Sceptredoc'
htmlhelp_basename = "Sceptredoc"

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

Expand All @@ -133,14 +133,14 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Sceptre.tex', 'Sceptre Documentation', 'Cloudreach', 'manual')
(master_doc, "Sceptre.tex", "Sceptre Documentation", "Cloudreach", "manual")
]

# -- Options for manual page output ------------------------------------------

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

# -- Options for Texinfo output ----------------------------------------------

Expand All @@ -150,12 +150,12 @@
texinfo_documents = [
(
master_doc,
'Sceptre',
'Sceptre Documentation',
"Sceptre",
"Sceptre Documentation",
author,
'Sceptre',
'One line description of project.',
'Miscellaneous',
"Sceptre",
"One line description of project.",
"Miscellaneous",
)
]

Expand All @@ -177,41 +177,38 @@
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]

# -- Extension configuration -------------------------------------------------

# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'boto3': (
'https://boto3.amazonaws.com/v1/documentation/api/latest/',
'https://boto3.amazonaws.com/v1/documentation/api/latest/objects.inv',
"python": ("https://docs.python.org/3/", None),
"boto3": (
"https://boto3.amazonaws.com/v1/documentation/api/latest/",
"https://boto3.amazonaws.com/v1/documentation/api/latest/objects.inv",
),
'deepdiff': (
'https://zepworks.com/deepdiff/current/',
None
)
"deepdiff": ("https://zepworks.com/deepdiff/current/", None),
}

# other configuration

nitpicky = True

nitpick_ignore = [
('py:class', 'json.encoder.JSONEncoder'),
('py:class', 'sceptre.config.reader.Attributes'),
('py:class', 'sceptre.diffing.stack_differ.DiffType'),
('py:obj', 'sceptre.diffing.stack_differ.DiffType'),
('py:class', 'DiffType'),
('py:class', 'TextIO'),
('py:class', '_io.StringIO'),
('py:class', 'yaml.loader.SafeLoader'),
('py:class', 'yaml.dumper.Dumper'),
('py:class', 'cfn_tools.odict.ODict'),
('py:class', 'T_Container')
("py:class", "json.encoder.JSONEncoder"),
("py:class", "sceptre.config.reader.Attributes"),
("py:class", "sceptre.diffing.stack_differ.DiffType"),
("py:obj", "sceptre.diffing.stack_differ.DiffType"),
("py:class", "DiffType"),
("py:class", "TextIO"),
("py:class", "_io.StringIO"),
("py:class", "yaml.loader.SafeLoader"),
("py:class", "yaml.dumper.Dumper"),
("py:class", "cfn_tools.odict.ODict"),
("py:class", "T_Container"),
]

set_type_checking_flag = True
40 changes: 15 additions & 25 deletions integration-tests/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@


def before_all(context):
random_str = ''.join(random.choices(string.ascii_lowercase + string.digits, k=16))
context.TEST_ARTIFACT_BUCKET_NAME = f'sceptre-test-artifacts-{random_str}'
random_str = "".join(random.choices(string.ascii_lowercase + string.digits, k=16))
context.TEST_ARTIFACT_BUCKET_NAME = f"sceptre-test-artifacts-{random_str}"
context.region = boto3.session.Session().region_name
context.uuid = uuid.uuid1().hex
context.project_code = "sceptre-integration-tests-{0}".format(
context.uuid
)
context.project_code = "sceptre-integration-tests-{0}".format(context.uuid)

sts = boto3.client("sts")
account_number = sts.get_caller_identity()['Account']
account_number = sts.get_caller_identity()["Account"]
context.bucket_name = "sceptre-integration-tests-templates-{}".format(
account_number
)
Expand All @@ -26,12 +24,10 @@ def before_all(context):
os.getcwd(), "integration-tests", "sceptre-project"
)
update_config(context)
context.cloudformation = boto3.resource('cloudformation')
context.cloudformation = boto3.resource("cloudformation")
context.client = boto3.client("cloudformation")

config_path = os.path.join(
context.sceptre_dir, "config", "9/B" + ".yaml"
)
config_path = os.path.join(context.sceptre_dir, "config", "9/B" + ".yaml")

with open(config_path, "r") as file:
file_data = file.read()
Expand All @@ -51,28 +47,22 @@ def before_scenario(context, scenario):


def update_config(context):
config_path = os.path.join(
context.sceptre_dir, "config", "config.yaml"
)
config_path = os.path.join(context.sceptre_dir, "config", "config.yaml")
with open(config_path) as config_file:
stack_group_config = yaml.safe_load(config_file)

stack_group_config["template_bucket_name"] = context.bucket_name
stack_group_config["project_code"] = context.project_code

with open(config_path, 'w') as config_file:
yaml.safe_dump(
stack_group_config, config_file, default_flow_style=False
)
with open(config_path, "w") as config_file:
yaml.safe_dump(stack_group_config, config_file, default_flow_style=False)


def after_all(context):
response = context.client.describe_stacks()
for stack in response["Stacks"]:
if stack["StackName"].startswith(context.project_code):
context.client.delete_stack(
StackName=stack["StackName"]
)
context.client.delete_stack(StackName=stack["StackName"])
time.sleep(2)
context.project_code = "sceptre-integration-tests"
context.bucket_name = "sceptre-integration-tests-templates"
Expand All @@ -84,20 +74,20 @@ def before_feature(context, feature):
Create a test bucket with a unique name and upload test artifact to the bucket
for the S3 template handler to reference
"""
if 's3-template-handler' in feature.tags:
bucket = boto3.resource('s3').Bucket(context.TEST_ARTIFACT_BUCKET_NAME)
if "s3-template-handler" in feature.tags:
bucket = boto3.resource("s3").Bucket(context.TEST_ARTIFACT_BUCKET_NAME)
if bucket.creation_date is None:
bucket.create(
CreateBucketConfiguration={'LocationConstraint': context.region}
CreateBucketConfiguration={"LocationConstraint": context.region}
)


def after_feature(context, feature):
"""
Do a full cleanup of the test artifacts and the test bucket
"""
if 's3-template-handler' in feature.tags:
bucket = boto3.resource('s3').Bucket(context.TEST_ARTIFACT_BUCKET_NAME)
if "s3-template-handler" in feature.tags:
bucket = boto3.resource("s3").Bucket(context.TEST_ARTIFACT_BUCKET_NAME)
if bucket.creation_date is not None:
bucket.objects.all().delete()
bucket.delete()
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
if __name__ == '__main__':
if __name__ == "__main__":
pass
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

def sceptre_handler(scepter_user_data):
template = {
"Resources": {
"WaitConditionHandle": {
"Type": "AWS::CloudFormation::WaitConditionHandle",
"Properties": {}
"Resources": {
"WaitConditionHandle": {
"Type": "AWS::CloudFormation::WaitConditionHandle",
"Properties": {},
}
}
}
}
return json.dumps(template)
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

def sceptre_handler(scepter_user_data):
template = {
"Resources": {
"WaitConditionHandle": {
"Type": "AWS::CloudFormation::WaitConditionHandle",
"Properties": {}
"Resources": {
"WaitConditionHandle": {
"Type": "AWS::CloudFormation::WaitConditionHandle",
"Properties": {},
}
}
}
}
return yaml.dump(template)
Loading

0 comments on commit 40e4d80

Please sign in to comment.