[Python-modules-commits] [python-attrs] 01/03: Import python-attrs_15.2.0.tar.gz

Tristan Seligmann mithrandi at moszumanska.debian.org
Sun Feb 21 07:03:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

mithrandi pushed a commit to branch master
in repository python-attrs.

commit 2d9191a8b72d88d9e7f1525e00075ba19b5dd0e5
Author: Tristan Seligmann <mithrandi at mithrandi.net>
Date:   Sun Feb 21 08:20:13 2016 +0200

    Import python-attrs_15.2.0.tar.gz
---
 .gitignore                      |   8 +
 .travis.yml                     |  47 ++++
 CHANGELOG.rst                   |  44 +++
 CODE_OF_CONDUCT.rst             |  37 +++
 CONTRIBUTING.rst                |  41 +++
 LICENSE                         |  21 ++
 MANIFEST.in                     |   5 +
 README.rst                      |  59 ++++
 conftest.py                     |  19 ++
 docs/Makefile                   | 177 ++++++++++++
 docs/api.rst                    | 253 +++++++++++++++++
 docs/backward-compatibility.rst |  19 ++
 docs/changelog.rst              |   1 +
 docs/conf.py                    | 306 +++++++++++++++++++++
 docs/contributing.rst           |   3 +
 docs/examples.rst               | 425 +++++++++++++++++++++++++++++
 docs/extending.rst              |  38 +++
 docs/index.rst                  |  40 +++
 docs/license.rst                |  18 ++
 docs/why.rst                    | 221 +++++++++++++++
 setup.cfg                       |   9 +
 setup.py                        |  82 ++++++
 src/attr/__init__.py            |  60 +++++
 src/attr/_compat.py             |  26 ++
 src/attr/_config.py             |  23 ++
 src/attr/_funcs.py              |  91 +++++++
 src/attr/_make.py               | 581 ++++++++++++++++++++++++++++++++++++++++
 src/attr/filters.py             |  53 ++++
 src/attr/validators.py          | 114 ++++++++
 tests/__init__.py               |  42 +++
 tests/test_config.py            |  43 +++
 tests/test_dark_magic.py        | 119 ++++++++
 tests/test_dunders.py           | 318 ++++++++++++++++++++++
 tests/test_filters.py           |  92 +++++++
 tests/test_funcs.py             | 154 +++++++++++
 tests/test_make.py              | 466 ++++++++++++++++++++++++++++++++
 tests/test_validators.py        | 155 +++++++++++
 tox.ini                         |  50 ++++
 38 files changed, 4260 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..321aae5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+.tox
+.coverage*
+*.pyc
+*.egg-info
+docs/_build/
+htmlcov
+dist
+.cache
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..2a70928
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,47 @@
+sudo: false
+cache:
+  directories:
+    - $HOME/.cache/pip
+
+language: python
+
+
+matrix:
+  include:
+    - python: "2.6"  # these are just to make travis's UI a bit prettier
+      env: TOXENV=py26
+    - python: "2.7"
+      env: TOXENV=py27
+    - python: "3.3"
+      env: TOXENV=py33
+    - python: "3.4"
+      env: TOXENV=py34
+    - python: "3.5"
+      env: TOXENV=py35
+    - python: "pypy"
+      env: TOXENV=pypy
+
+    # Meta
+    - python: "3.5"
+      env: TOXENV=flake8
+    - python: "2.7"
+      env: TOXENV=manifest
+    - python: "2.7"
+      env: TOXENV=docs
+
+
+install:
+  - pip install tox
+
+script:
+  - tox --hashseed 0
+
+before_install:
+  - pip install codecov
+
+after_success:
+  - tox -e coverage-report
+  - codecov
+
+notifications:
+  email: false
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
new file mode 100644
index 0000000..af64f6c
--- /dev/null
+++ b/CHANGELOG.rst
@@ -0,0 +1,44 @@
+Changelog
+=========
+
+Versions are year-based with a strict backwards compatibility policy.
+The third digit is only for regressions.
+
+
+15.2.0 (2015-12-08)
+-------------------
+
+
+Changes:
+^^^^^^^^
+
+- Add a ``convert`` argument to ``attr.ib``, which allows specifying a function to run on arguments.
+  This allows for simple type conversions, e.g. with ``attr.ib(convert=int)``.
+  `[26] <https://github.com/hynek/attrs/issues/26>`_
+- Speed up object creation when attribute validators are used.
+  `[28] <https://github.com/hynek/attrs/issues/28>`_
+
+
+15.1.0 (2015-08-20)
+-------------------
+
+
+Changes:
+^^^^^^^^
+
+- Add ``attr.validators.optional`` that wraps other validators allowing attributes to be ``None``.
+  `[16] <https://github.com/hynek/attrs/issues/16>`_
+- Fix multi-level inheritance.
+  `[24] <https://github.com/hynek/attrs/issues/24>`_
+- Fix ``__repr__`` to work for non-redecorated subclasses.
+  `[20] <https://github.com/hynek/attrs/issues/20>`_
+
+
+15.0.0 (2015-04-15)
+-------------------
+
+
+Changes:
+^^^^^^^^
+
+Initial release.
diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst
new file mode 100644
index 0000000..1623397
--- /dev/null
+++ b/CODE_OF_CONDUCT.rst
@@ -0,0 +1,37 @@
+Contributor Code of Conduct
+===========================
+
+As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
+
+We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery
+* Personal attacks
+* Trolling or insulting/derogatory comments
+* Public or private harassment
+* Publishing other's private information, such as physical or electronic
+  addresses, without explicit permission
+* Other unethical or unprofessional conduct
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project.
+Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer at hs at ox.cx.
+All complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances.
+Maintainers are obligated to maintain confidentiality with regard to the reporter of an
+incident.
+
+
+This Code of Conduct is adapted from the `Contributor Covenant <homepage>`_,
+version 1.3.0, available at
+`http://contributor-covenant.org/version/1/3/0/ <version>`_.
+
+.. _homepage: http://contributor-covenant.org
+.. _version: http://contributor-covenant.org/version/1/3/0/
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..482934d
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,41 @@
+How To Contribute
+=================
+
+Every open source project lives from the generous help by contributors that sacrifice their time and ``attrs`` is no different.
+
+Here are a few guidelines to get you started:
+
+- Try to limit each pull request to one change only.
+- To run the test suite, all you need is a recent tox_.
+  It will ensure the test suite runs with all dependencies against all Python versions just as it will on `Travis CI`_.
+  If you lack some Python version, you can can always limit the environments like ``tox -e py27,py35`` (in that case you may want to look into pyenv_ that makes it very easy to install many different Python versions in parallel).
+- Make sure your changes pass our CI.
+  You won't get any feedback until it's green unless you ask for it.
+- If your change is noteworthy, add an entry to the changelog_.
+  Use present tense, semantic newlines, and add link to your pull request.
+- No contribution is too small; please submit as many fixes for typos and grammar bloopers as you can!
+- Don’t break `backward compatibility`_.
+- *Always* add tests and docs for your code.
+  This is a hard rule; patches with missing tests or documentation won’t be merged.
+- Write `good test docstrings`_.
+- Obey `PEP 8`_ and `PEP 257`_.
+- If you address review feedback, make sure to bump the pull request.
+  Maintainers don’t receive notifications if you push new commits.
+
+Please note that this project is released with a Contributor `Code of Conduct`_.
+By participating in this project you agree to abide by its terms.
+Please report any harm to `Hynek Schlawack <me>`_ in any way you find appropriate.
+
+Thank you for considering to contribute to ``attrs``!
+
+
+.. _me: https://hynek.me/about/
+.. _`PEP 8`: https://www.python.org/dev/peps/pep-0008/
+.. _`PEP 257`: https://www.python.org/dev/peps/pep-0257/
+.. _`good test docstrings`: https://jml.io/pages/test-docstrings.html
+.. _`Code of Conduct`: https://github.com/hynek/attrs/blob/master/CODE_OF_CONDUCT.rst
+.. _changelog: https://github.com/hynek/attrs/blob/master/CHANGELOG.rst
+.. _`backward compatibility`: https://attrs.readthedocs.org/en/latest/backward-compatibility.html
+.. _`tox`: https://testrun.org/tox/
+.. _`Travis CI`: https://travis-ci.org/
+.. _pyenv: https://github.com/yyuu/pyenv
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..7ae3df9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Hynek Schlawack
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..483a3a3
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+include *.rst *.txt LICENSE tox.ini .travis.yml docs/Makefile .coveragerc conftest.py
+recursive-include tests *.py
+recursive-include docs *.rst
+recursive-include docs *.py
+prune docs/_build
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..b79b1fd
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,59 @@
+======================================
+attrs: Attributes without boilerplate.
+======================================
+
+.. image:: https://travis-ci.org/hynek/attrs.svg
+   :target: https://travis-ci.org/hynek/attrs
+   :alt: CI status
+
+.. image:: https://codecov.io/github/hynek/attrs/coverage.svg?branch=master
+   :target: https://codecov.io/github/hynek/attrs?branch=master
+   :alt: Coverage
+
+.. teaser-begin
+
+``attrs`` is an `MIT <http://choosealicense.com/licenses/mit/>`_-licensed Python package with class decorators that ease the chores of implementing the most common attribute-related object protocols:
+
+.. code-block:: pycon
+
+   >>> import attr
+   >>> @attr.s
+   ... class C(object):
+   ...     x = attr.ib(default=42)
+   ...     y = attr.ib(default=attr.Factory(list))
+   >>> i = C(x=1, y=2)
+   >>> i
+   C(x=1, y=2)
+   >>> i == C(1, 2)
+   True
+   >>> i != C(2, 1)
+   True
+   >>> attr.asdict(i)
+   {'y': 2, 'x': 1}
+   >>> C()
+   C(x=42, y=[])
+   >>> C2 = attr.make_class("C2", ["a", "b"])
+   >>> C2("foo", "bar")
+   C2(a='foo', b='bar')
+
+(If you don’t like the playful ``attr.s`` and ``attr.ib``, you can also use their no-nonsense aliases ``attr.attributes`` and ``attr.attr``).
+
+You just specify the attributes to work with and ``attrs`` gives you:
+
+- a nice human-readable ``__repr__``,
+- a complete set of comparison methods,
+- an initializer,
+- and much more
+
+*without* writing dull boilerplate code again and again.
+
+This gives you the power to use actual classes with actual types in your code instead of confusing ``tuple``\ s or confusingly behaving ``namedtuple``\ s.
+
+So put down that type-less data structures and welcome some class into your life!
+
+.. note::
+   I wrote an `explanation <https://attrs.readthedocs.org/en/latest/why.html#characteristic>`_ on why I forked my own ``characteristic``.
+   It's not dead but ``attrs`` will have more new features.
+
+``attrs``\ ’s documentation lives at `Read the Docs <https://attrs.readthedocs.org/>`_, the code on `GitHub <https://github.com/hynek/attrs>`_.
+It’s rigorously tested on Python 2.6, 2.7, 3.3+, and PyPy.
diff --git a/conftest.py b/conftest.py
new file mode 100644
index 0000000..2fd79e9
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,19 @@
+from __future__ import absolute_import, division, print_function
+
+
+import pytest
+
+
+ at pytest.fixture(scope="session")
+def C():
+    """
+    Return a simple but fully features attrs class with an x and a y attribute.
+    """
+    from attr import attributes, attr
+
+    @attributes
+    class C(object):
+        x = attr()
+        y = attr()
+
+    return C
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..3143891
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,177 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  xml        to make Docutils-native XML files"
+	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/attrs.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/attrs.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/attrs"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/attrs"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through platex and dvipdfmx..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+	@echo
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+	@echo
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/docs/api.rst b/docs/api.rst
new file mode 100644
index 0000000..995166f
--- /dev/null
+++ b/docs/api.rst
@@ -0,0 +1,253 @@
+.. _api:
+
+API
+===
+
+.. currentmodule:: attr
+
+``attrs`` works by decorating a class using :func:`attr.s` and then optionally defining attributes on the class using :func:`attr.ib`.
+
+.. note::
+
+   When this documentation speaks about "``attrs`` attributes" it means those attributes that are defined using :func:`attr.ib` in the class body.
+
+What follows is the API explanation, if you'd like a more hands-on introduction, have a look at :doc:`examples`.
+
+
+
+Core
+----
+
+.. autofunction:: attr.s(these=None, repr_ns=None, repr=True, cmp=True, hash=True, init=True)
+
+   .. note::
+
+      ``attrs`` also comes with a less playful alias ``attr.attributes``.
+
+   For example:
+
+   .. doctest::
+
+      >>> import attr
+      >>> @attr.s
+      ... class C(object):
+      ...     _private = attr.ib()
+      >>> C(private=42)
+      C(_private=42)
+      >>> class D(object):
+      ...     def __init__(self, x):
+      ...         self.x = x
+      >>> D(1)
+      <D object at ...>
+      >>> D = attr.s(these={"x": attr.ib()}, init=False)(D)
+      >>> D(1)
+      D(x=1)
+
+
+.. autofunction:: attr.ib
+
+   .. note::
+
+      ``attrs`` also comes with a less playful alias ``attr.attr``.
+
+
+.. autoclass:: attr.Attribute
+
+   Instances of this class are frequently used for introspection purposes like:
+
+   - Class attributes on ``attrs``-decorated classes *after* ``@attr.s`` has been applied.
+   - :func:`fields` returns a tuple of them.
+   - Validators get them passed as the first argument.
+
+   .. warning::
+
+       You should never instantiate this class yourself!
+
+   .. doctest::
+
+      >>> import attr
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib()
+      >>> C.x
+      Attribute(name='x', default=NOTHING, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None)
+
+
+.. autofunction:: attr.make_class
+
+   This is handy if you want to programmatically create classes.
+
+   For example:
+
+   .. doctest::
+
+      >>> C1 = attr.make_class("C1", ["x", "y"])
+      >>> C1(1, 2)
+      C1(x=1, y=2)
+      >>> C2 = attr.make_class("C2", {"x": attr.ib(default=42),
+      ...                             "y": attr.ib(default=attr.Factory(list))})
+      >>> C2()
+      C2(x=42, y=[])
+
+
+.. autoclass:: attr.Factory
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib(default=attr.Factory(list))
+      >>> C()
+      C(x=[])
+
+
+Helpers
+-------
+
+``attrs`` comes with a bunch of helper methods that make the work with it easier:
+
+.. autofunction:: attr.fields
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib()
+      ...     y = attr.ib()
+      >>> attr.fields(C)
+      (Attribute(name='x', default=NOTHING, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None), Attribute(name='y', default=NOTHING, validator=None, repr=True, cmp=True, hash=True, init=True, convert=None))
+
+
+.. autofunction:: attr.has
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     pass
+      >>> attr.has(C)
+      True
+      >>> attr.has(object)
+      False
+
+
+.. autofunction:: attr.asdict
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib()
+      ...     y = attr.ib()
+      >>> attr.asdict(C(1, C(2, 3)))
+      {'y': {'y': 3, 'x': 2}, 'x': 1}
+
+
+``attrs`` comes with some handy helpers for filtering:
+
+.. autofunction:: attr.filters.include
+
+.. autofunction:: attr.filters.exclude
+
+
+.. autofunction:: assoc
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib()
+      ...     y = attr.ib()
+      >>> i1 = C(1, 2)
+      >>> i1
+      C(x=1, y=2)
+      >>> i2 = attr.assoc(i1, y=3)
+      >>> i2
+      C(x=1, y=3)
+      >>> i1 == i2
+      False
+
+
+.. autofunction:: validate
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib(validator=attr.validators.instance_of(int))
+      >>> i = C(1)
+      >>> i.x = "1"
+      >>> attr.validate(i)
+      Traceback (most recent call last):
+         ...
+      TypeError: ("'x' must be <type 'int'> (got '1' that is a <type 'str'>).", Attribute(name='x', default=NOTHING, validator=<instance_of validator for type <type 'int'>>, repr=True, cmp=True, hash=True, init=True), <type 'int'>, '1')
+
+
+Validators can be globally disabled if you want to run them only in development and tests but not in production because you fear their performance impact:
+
+.. autofunction:: set_run_validators
+
+.. autofunction:: get_run_validators
+
+
+.. _api_validators:
+
+Validators
+----------
+
+``attrs`` comes with some common validators within the ``attrs.validators`` module:
+
+
+.. autofunction:: attr.validators.instance_of
+
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib(validator=attr.validators.instance_of(int))
+      >>> C(42)
+      C(x=42)
+      >>> C("42")
+      Traceback (most recent call last):
+         ...
+      TypeError: ("'x' must be <type 'int'> (got '42' that is a <type 'str'>).", Attribute(name='x', default=NOTHING, validator=<instance_of validator for type <type 'int'>>), <type 'int'>, '42')
+      >>> C(None)
+      Traceback (most recent call last):
+         ...
+      TypeError: ("'x' must be <type 'int'> (got None that is a <type 'NoneType'>).", Attribute(name='x', default=NOTHING, validator=<instance_of validator for type <type 'int'>>, repr=True, cmp=True, hash=True, init=True), <type 'int'>, None)
+
+
+.. autofunction:: attr.validators.provides
+
+.. autofunction:: attr.validators.optional
+
+   For example:
+
+   .. doctest::
+
+      >>> @attr.s
+      ... class C(object):
+      ...     x = attr.ib(validator=attr.validators.optional(attr.validators.instance_of(int)))
+      >>> C(42)
+      C(x=42)
+      >>> C("42")
+      Traceback (most recent call last):
+         ...
+      TypeError: ("'x' must be <type 'int'> (got '42' that is a <type 'str'>).", Attribute(name='x', default=NOTHING, validator=<instance_of validator for type <type 'int'>>), <type 'int'>, '42')
+      >>> C(None)
+      C(x=None)
diff --git a/docs/backward-compatibility.rst b/docs/backward-compatibility.rst
new file mode 100644
index 0000000..e8fff8f
--- /dev/null
+++ b/docs/backward-compatibility.rst
@@ -0,0 +1,19 @@
+Backward Compatibility
+======================
+
+.. currentmodule:: attr
+
+``attrs`` has a very strong backward compatibility policy that is inspired by the one of the `Twisted framework <https://twistedmatrix.com/trac/wiki/CompatibilityPolicy>`_.
+
+Put simply, you shouldn't ever be afraid to upgrade ``attrs`` if you're using its public APIs.
+If there will ever be need to break compatibility, it will be announced in the :doc:`changelog`, raise deprecation warning for a year before it's finally really broken.
+
+
+.. _exemption:
+
+.. warning::
+
+   The structure of the :class:`attr.Attribute` class is exempted from this rule.
+   It *will* change in the future since it should be considered read-only, that shouldn't matter.
+
+   However if you intend to build extensions on top of ``attrs`` you have to anticipate that.
diff --git a/docs/changelog.rst b/docs/changelog.rst
new file mode 100644
index 0000000..565b052
--- /dev/null
+++ b/docs/changelog.rst
@@ -0,0 +1 @@
+.. include:: ../CHANGELOG.rst
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..cacf3c2
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,306 @@
+# -*- coding: utf-8 -*-
+#
+# attrs documentation build configuration file, created by
+# sphinx-quickstart on Sun May 11 16:17:15 2014.
+#
+# 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.
+
+import codecs
+import datetime
+import os
+import re
+
+try:
+    import sphinx_rtd_theme
+except ImportError:
+    sphinx_rtd_theme = None
+
+
+def read(*parts):
+    """
+    Build an absolute path from *parts* and and return the contents of the
+    resulting file.  Assume UTF-8 encoding.
+    """
+    here = os.path.abspath(os.path.dirname(__file__))
+    with codecs.open(os.path.join(here, *parts), "rb", "utf-8") as f:
+        return f.read()
+
+
+def find_version(*file_paths):
+    """
+    Build a path from *file_paths* and search for a ``__version__``
+    string inside.
+    """
+    version_file = read(*file_paths)
+    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
+                              version_file, re.M)
+    if version_match:
+        return version_match.group(1)
+    raise RuntimeError("Unable to find version string.")
+
+# 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('.'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#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.
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.doctest',
+    'sphinx.ext.intersphinx',
+    'sphinx.ext.todo',
+]
+
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'attrs'
+year = datetime.date.today().year
+copyright = u'2015{0}, Hynek Schlawack'.format(
+    u'-{0}'.format(year) if year != 2015 else u""
+)
+
+# 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.
+release = find_version("../src/attr/__init__.py")
+version = release.rsplit(u".", 1)[0]
+# The full version, including alpha/beta/rc tags.
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#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
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#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
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#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 = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
... 3534 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-attrs.git



More information about the Python-modules-commits mailing list