Skip to content

Commit af07227

Browse files
authored
Merge pull request #353 from nifadyev/#350/add-nox-support
#350: Add Nox and basic pyproject.toml created by Poetry
2 parents 15429d0 + f956856 commit af07227

File tree

6 files changed

+223
-36
lines changed

6 files changed

+223
-36
lines changed

README.md

+20-36
Original file line numberDiff line numberDiff line change
@@ -289,53 +289,37 @@ This saved one line of code, and implicitly prevented invoking `some_func` twice
289289
### ▶ Strings can be tricky sometimes
290290
291291
<!-- Example ID: 30f1d3fc-e267-4b30-84ef-4d9e7091ac1a --->
292-
1\.
293-
294-
```py
295-
>>> a = "some_string"
296-
>>> id(a)
297-
140420665652016
298-
>>> id("some" + "_" + "string") # Notice that both the ids are same.
299-
140420665652016
300-
```
301-
302-
2\.
303292
304-
```py
305-
>>> a = "wtf"
306-
>>> b = "wtf"
307-
>>> a is b
308-
True
309-
310-
>>> a = "wtf!"
311-
>>> b = "wtf!"
312-
>>> a is b
313-
False
293+
1\. Notice that both the ids are same.
314294
295+
```python:snippets/2_tricky_strings.py -s 2 -e 3
296+
assert id("some_string") == id("some" + "_" + "string")
297+
assert id("some_string") == id("some_string")
315298
```
316299
317-
3\.
300+
2\. `True` because it is invoked in script. Might be `False` in `python shell` or `ipython`
318301
319-
```py
320-
>>> a, b = "wtf!", "wtf!"
321-
>>> a is b # All versions except 3.7.x
322-
True
302+
```python:snippets/2_tricky_strings.py -s 6 -e 12
303+
a = "wtf"
304+
b = "wtf"
305+
assert a is b
323306
324-
>>> a = "wtf!"; b = "wtf!"
325-
>>> a is b # This will print True or False depending on where you're invoking it (python shell / ipython / as a script)
326-
False
327-
```
328-
329-
```py
330-
# This time in file some_file.py
331307
a = "wtf!"
332308
b = "wtf!"
333-
print(a is b)
309+
assert a is b
310+
```
311+
312+
3\. `True` because it is invoked in script. Might be `False` in `python shell` or `ipython`
313+
314+
```python:snippets/2_tricky_strings.py -s 15 -e 19
315+
a, b = "wtf!", "wtf!"
316+
assert a is b
334317
335-
# prints True when the module is invoked!
318+
a = "wtf!"; b = "wtf!"
319+
assert a is b
336320
```
337321
338-
4\.
322+
4\. __Disclaimer - snippet is not relavant in modern Python versions__
339323
340324
**Output (< Python3.7 )**
341325

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)