diff --git a/docs/conf.py b/docs/conf.py index 3ceafa5..10ca6ad 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,20 +1,23 @@ -# -*- coding: utf-8 -*- # # zope.security documentation build configuration file, created by # sphinx-quickstart on Sun Dec 23 12:19:39 2012. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is execfile()d with the current directory set to its containing +# dir. # # Note that not all possible configuration values are present in this # autogenerated file. # -# All configuration values have a default; values that are commented out -# serve to show the default. +# All configuration values have a default; values that are commented out serve +# to show the default. import os import sys + import pkg_resources + + sys.path.append(os.path.abspath('../src')) rqmt = pkg_resources.require('zope.security')[0] @@ -24,15 +27,15 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) -# -- General configuration ----------------------------------------------------- +# -- General configuration ----------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', @@ -46,17 +49,17 @@ templates_path = ['_templates'] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = {'.rst': 'restructuredtext'} # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. -project = u'zope.security' -copyright = u'2012, Zope Foundation Contributors ' +project = 'zope.security' +copyright = '2012, Zope Foundation Contributors ' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -69,40 +72,41 @@ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] -# -- Options for HTML output --------------------------------------------------- +# -- Options for HTML output --------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. @@ -111,26 +115,26 @@ # 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 = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # 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, @@ -139,137 +143,148 @@ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'zopesecuritydoc' -# -- Options for LaTeX output -------------------------------------------------- +# -- Options for LaTeX output -------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', } -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). +# Grouping the document tree into LaTeX files. List of tuples (source start +# file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'zopesecurity.tex', u'zope.security Documentation', - u'Zope Foundation Contributors \\textless{}zope-dev@zope.org\\textgreater{}', 'manual'), + ('index', + 'zopesecurity.tex', + 'zope.security Documentation', + 'Zope Foundation Contributors \\textless{}zope-dev@zope.org' + '\\textgreater{}', + 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True -# -- Options for manual page output -------------------------------------------- +# -- Options for manual page output -------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'zopesecurity', u'zope.security Documentation', - [u'Zope Foundation Contributors '], 1) + ('index', 'zopesecurity', 'zope.security Documentation', + ['Zope Foundation Contributors '], 1) ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False -# -- Options for Texinfo output ------------------------------------------------ +# -- Options for Texinfo output ------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'zopesecurity', u'zope.security Documentation', - u'Zope Foundation Contributors ', 'zopesecurity', 'One line description of project.', - 'Miscellaneous'), + ('index', + 'zopesecurity', + 'zope.security Documentation', + 'Zope Foundation Contributors ', + 'zopesecurity', + 'One line description of project.', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - 'https://docs.python.org/3/': None, - 'https://zopeinterface.readthedocs.io/en/latest': None, - 'https://zopeproxy.readthedocs.io/en/latest': None, - 'https://zopeschema.readthedocs.io/en/latest': None, - 'https://zopelocation.readthedocs.io/en/latest': None, + 'python': ('https://docs.python.org/3/', None), + 'zopeinterface': ('https://zopeinterface.readthedocs.io/en/latest', None), + 'zopeproxy': ('https://zopeproxy.readthedocs.io/en/latest', None), + 'zopeschema': ('https://zopeschema.readthedocs.io/en/latest', None), + 'zopelocation': ('https://zopelocation.readthedocs.io/en/latest', None), } -extlinks = {'issue': ('https://github.com/zopefoundation/zope.security/issues/%s', - 'issue #'), - 'pr': ('https://github.com/zopefoundation/zope.security/pull/%s', - 'pull request #')} +extlinks = { + 'issue': ( + 'https://github.com/zopefoundation/zope.security/issues/%s', + 'issue #'), + 'pr': ( + 'https://github.com/zopefoundation/zope.security/pull/%s', + 'pull request #')} autodoc_default_flags = [ 'members', diff --git a/src/zope/security/checker.py b/src/zope/security/checker.py index 861317b..d679f32 100644 --- a/src/zope/security/checker.py +++ b/src/zope/security/checker.py @@ -304,7 +304,7 @@ def getInfo(self): try: cls = self.obj.__class__ if hasattr(cls, "__module__"): - s = "{}.{}".format(cls.__module__, cls.__name__) + s = f"{cls.__module__}.{cls.__name__}" else: # pragma: no cover XXX s = str(cls.__name__) result.append(" - class: " + s) @@ -313,7 +313,7 @@ def getInfo(self): try: cls = type(self.obj) if hasattr(cls, "__module__"): - s = "{}.{}".format(cls.__module__, cls.__name__) + s = f"{cls.__module__}.{cls.__name__}" else: # pragma: no cover XXX s = str(cls.__name__) result.append(" - type: " + s) @@ -617,14 +617,14 @@ def check(self, object, name): % (name, object), 2) else: self._log( - '[CHK] + Granted: {} on {!r}'.format(name, object), 2) + f'[CHK] + Granted: {name} on {object!r}', 2) except Unauthorized: self._log( - '[CHK] - Unauthorized: {} on {!r}'.format(name, object)) + f'[CHK] - Unauthorized: {name} on {object!r}') raise except ForbiddenAttribute: self._log( - '[CHK] - Forbidden: {} on {!r}'.format(name, object)) + f'[CHK] - Forbidden: {name} on {object!r}') raise def check_getattr(self, object, name): @@ -641,12 +641,12 @@ def check_getattr(self, object, name): % (name, object), 2) except Unauthorized: self._log( - '[CHK] - Unauthorized getattr: {} on {!r}'.format(name, object) + f'[CHK] - Unauthorized getattr: {name} on {object!r}' ) raise except ForbiddenAttribute: self._log( - '[CHK] - Forbidden getattr: {} on {!r}'.format(name, object)) + f'[CHK] - Forbidden getattr: {name} on {object!r}') raise __setitem__ = check_getattr @@ -665,7 +665,7 @@ def check_setattr(self, object, name): raise except ForbiddenAttribute: self._log( - '[CHK] - Forbidden setattr: {} on {!r}'.format(name, object)) + f'[CHK] - Forbidden setattr: {name} on {object!r}') raise diff --git a/src/zope/security/examples/sandbox.py b/src/zope/security/examples/sandbox.py index b10d7b6..2c4f9cb 100644 --- a/src/zope/security/examples/sandbox.py +++ b/src/zope/security/examples/sandbox.py @@ -80,7 +80,7 @@ def getId(self): return self.id def __str__(self): - return "<{}> {}".format(str(self.__class__.__name__), str(self.id)) + return f"<{str(self.__class__.__name__)}> {str(self.id)}" __repr__ = __str__ diff --git a/src/zope/security/tests/test_checker.py b/src/zope/security/tests/test_checker.py index 22e9a1e..3167a1f 100644 --- a/src/zope/security/tests/test_checker.py +++ b/src/zope/security/tests/test_checker.py @@ -676,8 +676,8 @@ def test_getInfo_builtin_types(self): ]: tbs = self._makeOne(val) self.assertEqual(tbs.getInfo().splitlines(), - [' - class: builtins.{}'.format(typ), - ' - type: builtins.{}'.format(typ), + [f' - class: builtins.{typ}', + f' - type: builtins.{typ}', ]) def test_getInfo_newstyle_instance(self): diff --git a/src/zope/security/tests/test_proxy.py b/src/zope/security/tests/test_proxy.py index 63fef19..dd5fcdc 100644 --- a/src/zope/security/tests/test_proxy.py +++ b/src/zope/security/tests/test_proxy.py @@ -1278,7 +1278,7 @@ def test_binops(self): self.assertEqual( removeSecurityProxy(eval(expr)), z, - "x={!r}; y={!r}; expr={!r}".format(x, y, expr)) + f"x={x!r}; y={y!r}; expr={expr!r}") @unittest.skipIf(PURE_PYTHON, @@ -1743,7 +1743,7 @@ def test_unops(self): x = ProxyFactory(1, self.c) z = eval(expr) self.assertEqual(removeSecurityProxy(z), y, - "x={!r}; expr={!r}".format(x, expr)) + f"x={x!r}; expr={expr!r}") self.shouldFail(self._make_eval(expr, locals()), x) binops = [ @@ -1765,7 +1765,7 @@ def test_binops(self): self.assertEqual( removeSecurityProxy(eval(expr)), z, - "x={!r}; y={!r}; expr={!r}".format(x, y, expr)) + f"x={x!r}; y={y!r}; expr={expr!r}") self.shouldFail(self._make_eval(expr, locals()), x, y) def test_inplace(self): diff --git a/src/zope/security/tests/test_zcml_functest.py b/src/zope/security/tests/test_zcml_functest.py index 5186586..a478927 100644 --- a/src/zope/security/tests/test_zcml_functest.py +++ b/src/zope/security/tests/test_zcml_functest.py @@ -556,11 +556,11 @@ def testMimicAsDefault(self): attributes="m2 m3"/> '''.format( - _pfx("test_base"), - P1, - _pfx("test_class"), - _pfx("test_base"), - P2)) + _pfx("test_base"), + P1, + _pfx("test_class"), + _pfx("test_base"), + P2)) # m1 and m2 are in the interface, so should be set, and m3 should not: self.assertDeclaration(declaration,