Skip to content

Commit f251561

Browse files
committed
Configure Nox and basic Poetry support
- Use new structure for code blocks in README
1 parent 6abea7b commit f251561

File tree

6 files changed

+223
-35
lines changed

6 files changed

+223
-35
lines changed

README.md

+20-35
Original file line numberDiff line numberDiff line change
@@ -293,52 +293,37 @@ This saved one line of code, and implicitly prevented invoking `some_func` twice
293293
### ▶ Strings can be tricky sometimes
294294
295295
<!-- Example ID: 30f1d3fc-e267-4b30-84ef-4d9e7091ac1a --->
296-
1\.
297-
298-
```py
299-
>>> a = "some_string"
300-
>>> id(a)
301-
140420665652016
302-
>>> id("some" + "_" + "string") # Notice that both the ids are same.
303-
140420665652016
304-
```
305296
306-
2\.
307-
```py
308-
>>> a = "wtf"
309-
>>> b = "wtf"
310-
>>> a is b
311-
True
312-
313-
>>> a = "wtf!"
314-
>>> b = "wtf!"
315-
>>> a is b
316-
False
297+
1\. Notice that both the ids are same.
317298
299+
```python:snippets/2_tricky_strings.py -s 2 -e 3
300+
assert id("some_string") == id("some" + "_" + "string")
301+
assert id("some_string") == id("some_string")
318302
```
319303
320-
3\.
304+
2\. `True` because it is invoked in script. Might be `False` in `python shell` or `ipython`
321305
322-
```py
323-
>>> a, b = "wtf!", "wtf!"
324-
>>> a is b # All versions except 3.7.x
325-
True
306+
```python:snippets/2_tricky_strings.py -s 6 -e 12
307+
a = "wtf"
308+
b = "wtf"
309+
assert a is b
326310
327-
>>> a = "wtf!"; b = "wtf!"
328-
>>> a is b # This will print True or False depending on where you're invoking it (python shell / ipython / as a script)
329-
False
330-
```
331-
332-
```py
333-
# This time in file some_file.py
334311
a = "wtf!"
335312
b = "wtf!"
336-
print(a is b)
313+
assert a is b
314+
```
315+
316+
3\. `True` because it is invoked in script. Might be `False` in `python shell` or `ipython`
317+
318+
```python:snippets/2_tricky_strings.py -s 15 -e 19
319+
a, b = "wtf!", "wtf!"
320+
assert a is b
337321
338-
# prints True when the module is invoked!
322+
a = "wtf!"; b = "wtf!"
323+
assert a is b
339324
```
340325
341-
4\.
326+
4\. __Disclaimer - snippet is not relavant in modern Python versions__
342327
343328
**Output (< Python3.7 )**
344329

noxfile.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import TYPE_CHECKING
2+
3+
import nox
4+
5+
6+
if TYPE_CHECKING:
7+
from nox.sessions import Session
8+
9+
python_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]
10+
11+
@nox.session(python=python_versions, reuse_venv=True)
12+
def tests(session: "Session") -> None:
13+
_ = session.run("python", "snippets/2_tricky_strings.py")

poetry.lock

+155
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[tool.poetry]
2+
name = "wtfpython"
3+
version = "3.0.0"
4+
description = "What the f*ck Python!"
5+
authors = ["Satwik Kansal <[email protected]>"]
6+
license = "WTFPL 2.0"
7+
readme = "README.md"
8+
9+
[tool.poetry.dependencies]
10+
python = "^3.9"
11+
nox = "^2024.10.9"
12+
13+
14+
[build-system]
15+
requires = ["poetry-core"]
16+
build-backend = "poetry.core.masonry.api"

snippets/2_tricky_strings.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 1
2+
assert id("some_string") == id("some" + "_" + "string")
3+
assert id("some_string") == id("some_string")
4+
5+
# 2
6+
a = "wtf"
7+
b = "wtf"
8+
assert a is b
9+
10+
a = "wtf!"
11+
b = "wtf!"
12+
assert a is b
13+
14+
# 3
15+
a, b = "wtf!", "wtf!"
16+
assert a is b
17+
18+
a = "wtf!"; b = "wtf!"
19+
assert a is b

snippets/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)