From 57c94dc578869a6bc3d4e23711ea9108a6a5517e Mon Sep 17 00:00:00 2001
From: Vadim Nifadev <36514612+nifadyev@users.noreply.github.com>
Date: Thu, 17 Oct 2024 15:37:07 +0300
Subject: [PATCH] Configure Nox to run snippets on supported Python versions

---
 noxfile.py                   | 13 +++++++++++++
 snippets/2_tricky_strings.py | 31 +++++++++++++++++++++++++++++++
 snippets/__init__.py         |  0
 3 files changed, 44 insertions(+)
 create mode 100644 noxfile.py
 create mode 100644 snippets/2_tricky_strings.py
 create mode 100644 snippets/__init__.py

diff --git a/noxfile.py b/noxfile.py
new file mode 100644
index 00000000..f693b854
--- /dev/null
+++ b/noxfile.py
@@ -0,0 +1,13 @@
+from typing import TYPE_CHECKING
+
+import nox
+
+
+if TYPE_CHECKING:
+    from nox.sessions import Session
+
+python_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]
+
+@nox.session(python=python_versions, reuse_venv=True)
+def tests(session: "Session") -> None:
+    _ = session.run("python", "snippets/2_tricky_strings.py")
diff --git a/snippets/2_tricky_strings.py b/snippets/2_tricky_strings.py
new file mode 100644
index 00000000..ac94bc12
--- /dev/null
+++ b/snippets/2_tricky_strings.py
@@ -0,0 +1,31 @@
+# 1
+assert id("some_string") == id("some" + "_" + "string")
+assert id("some_string") == id("some_string")
+
+# 2
+a = "wtf"
+b = "wtf"
+assert a is b
+
+a = "wtf!"
+b = "wtf!"
+# True because it is invoked in script. Might be False in python shell or ipython
+assert a is b
+
+# 3
+a, b = "wtf!", "wtf!"
+assert a is b
+
+a = "wtf!"; b = "wtf!"  # noqa: E702 - multiline statement
+# True because it is invoked in script. Might be False in python shell or ipython
+assert a is b
+
+# 4 - not relevant for modern (>3.8) Python version, should be moved to `legacy` section
+# a = 'a' * 20
+# b = 'aaaaaaaaaaaaaaaaaaaa'
+# assert a is b
+#
+# a = 'a' * 21
+# b = 'aaaaaaaaaaaaaaaaaaaa'
+# # Fails
+# assert a is b
diff --git a/snippets/__init__.py b/snippets/__init__.py
new file mode 100644
index 00000000..e69de29b