Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merge dev branch into master #374

Merged
merged 13 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on: [pull_request]

permissions:
contents: read
pull-requests: read
checks: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Write git diff to temp file
run: |
git fetch origin
git diff origin/${{ github.base_ref }} --unified=0 *.md translations/*/*.md \
> ${{ runner.temp }}/diff.md
- uses: DavidAnson/markdownlint-cli2-action@v17
with:
globs: "${{ runner.temp }}/diff.md"
17 changes: 17 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MD013:
line_length: 120

# no-duplicate-heading - Multiple headings with the same content (Ignore multiple `Explanation` headings)
MD024: false

# no-trailing-punctuation - Trailing punctuation in heading (Ignore exclamation marks in headings)
MD026: false

# no-inline-html : Inline HTML (HTML is used for centered and theme specific images)
MD033: false

# no-inline-html : Bare URL used (site should be attributed transparently, because otherwise we have to un-necesarily explain where the link directs)
MD034: false

# first-line-h1 : First line in a file should be a top-level heading (Ignore because diff file will never have valid heading)
MD041: false
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default_language_version:
python: python3.12
repos:
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.14.0
hooks:
- id: markdownlint-cli2
819 changes: 476 additions & 343 deletions README.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -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")
155 changes: 155 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "wtfpython"
version = "3.0.0"
description = "What the f*ck Python!"
authors = ["Satwik Kansal <discuss@satwikkansal.xyz>"]
license = "WTFPL 2.0"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
nox = "^2024.10.9"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
19 changes: 19 additions & 0 deletions snippets/2_tricky_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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!"
assert a is b

# 3
a, b = "wtf!", "wtf!"
assert a is b

a = "wtf!"; b = "wtf!"
assert a is b
Empty file added snippets/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion translations/ru-russian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ False

Интерпретатор не понимает, что до выполнения выражения `y = 257` целое число со значением `257` уже создано, и поэтому он продолжает создавать другой объект в памяти.

Подобная оптимизация применима и к другим **изменяемым** объектам, таким как пустые кортежи. Поскольку списки являются изменяемыми, поэтому `[] is []` вернет `False`, а `() is ()` вернет `True`. Это объясняет наш второй фрагмент. Перейдем к третьему,
Подобная оптимизация применима и к другим **неизменяемым** объектам, таким как пустые кортежи. Поскольку списки являются изменяемыми, поэтому `[] is []` вернет `False`, а `() is ()` вернет `True`. Это объясняет наш второй фрагмент. Перейдем к третьему,

**И `a`, и `b` ссылаются на один и тот же объект при инициализации одним и тем же значением в одной и той же строке**.

Expand Down
Loading