]> git.madduck.net Git - etc/vim.git/blob - tests/data/simple_cases/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:

Explicitly annotate this with `Final[str]` to make it work in mypyc 1.0.0+. (#3645)
[etc/vim.git] / tests / data / simple_cases / 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 y = 1
26 (
27     # some strings
28     y  # type: ignore
29 )
30
31
32 def function(default=None):
33     """Docstring comes first.
34
35     Possibly many lines.
36     """
37     # FIXME: Some comment about why this function is crap but still in production.
38     import inner_imports
39
40     if inner_imports.are_evil():
41         # Explains why we have this if.
42         # In great detail indeed.
43         x = X()
44         return x.method1()  # type: ignore
45
46     # This return is also commented for some reason.
47     return default
48
49
50 # Explains why we use global state.
51 GLOBAL_STATE = {"a": a(1), "b": a(2), "c": a(3)}
52
53
54 # Another comment!
55 # This time two lines.
56
57
58 class Foo:
59     """Docstring for class Foo.  Example from Sphinx docs."""
60
61     #: Doc comment for class attribute Foo.bar.
62     #: It can have multiple lines.
63     bar = 1
64
65     flox = 1.5  #: Doc comment for Foo.flox. One line only.
66
67     baz = 2
68     """Docstring for class attribute Foo.baz."""
69
70     def __init__(self):
71         #: Doc comment for instance attribute qux.
72         self.qux = 3
73
74         self.spam = 4
75         """Docstring for instance attribute spam."""
76
77
78 #' <h1>This is pweave!</h1>
79
80
81 @fast(really=True)
82 async def wat():
83     # This comment, for some reason \
84     # contains a trailing backslash.
85     async with X.open_async() as x:  # Some more comments
86         result = await x.method1()
87     # Comment after ending a block.
88     if result:
89         print("A OK", file=sys.stdout)
90         # Comment between things.
91         print()
92
93
94 # Some closing comments.
95 # Maybe Vim or Emacs directives for formatting.
96 # Who knows.