]> 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:

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