]> git.madduck.net Git - etc/vim.git/blob - tests/comments.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

add sphinx docs skeleton (#71)
[etc/vim.git] / tests / comments.py
1 #!/usr/bin/env python3
2 # Some license here.
3 #
4 # Has many lines. Many, many lines.
5 # Many, many, many lines.
6 """Module docstring.
7
8 Possibly also many, many lines.
9 """
10
11 import os.path
12 import sys
13
14 import a
15 from b.c import X  # some noqa comment
16
17 try:
18     import fast
19 except ImportError:
20     import slow as fast
21
22
23 # Some comment before a function.
24
25
26 def function(default=None):
27     """Docstring comes first.
28
29     Possibly many lines.
30     """
31     # FIXME: Some comment about why this function is crap but still in production.
32     import inner_imports
33
34     if inner_imports.are_evil():
35         # Explains why we have this if.
36         # In great detail indeed.
37         x = X()
38         return x.method1()  # type: ignore
39
40     # This return is also commented for some reason.
41     return default
42
43
44 # Explains why we use global state.
45 GLOBAL_STATE = {'a': a(1), 'b': a(2), 'c': a(3)}
46
47
48 # Another comment!
49 # This time two lines.
50
51
52 class Foo:
53     """Docstring for class Foo.  Example from Sphinx docs."""
54
55     #: Doc comment for class attribute Foo.bar.
56     #: It can have multiple lines.
57     bar = 1
58
59     flox = 1.5  #: Doc comment for Foo.flox. One line only.
60
61     baz = 2
62     """Docstring for class attribute Foo.baz."""
63
64     def __init__(self):
65         #: Doc comment for instance attribute qux.
66         self.qux = 3
67
68         self.spam = 4
69         """Docstring for instance attribute spam."""
70
71
72 @fast(really=True)
73 async def wat():
74     async with X.open_async() as x:  # Some more comments
75         result = await x.method1()
76     # Comment after ending a block.
77     if result:
78         print('A OK', file=sys.stdout)
79         # Comment between things.
80         print()
81
82
83 # Some closing comments.
84 # Maybe Vim or Emacs directives for formatting.
85 # Who knows.