Skip to content
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
37 changes: 37 additions & 0 deletions _data/whats_left/builtin_items.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
builtin,name,is_inherited
BaseException,BaseException.__getattribute__,(inherited)
BaseException,BaseException.add_note,
NoneType,NoneType.__eq__,(inherited)
NoneType,NoneType.__ge__,(inherited)
NoneType,NoneType.__gt__,(inherited)
NoneType,NoneType.__hash__,(inherited)
NoneType,NoneType.__le__,(inherited)
NoneType,NoneType.__lt__,(inherited)
NoneType,NoneType.__ne__,(inherited)
bool,bool.__invert__,(inherited)
bytearray,bytearray.__buffer__,
bytearray,bytearray.__getattribute__,(inherited)
bytearray,bytearray.__release_buffer__,
bytearray,bytearray.__str__,(inherited)
bytes,bytes.__buffer__,
bytes,bytes.__getattribute__,(inherited)
bytes,bytes.__str__,(inherited)
classmethod,classmethod.__init__,(inherited)
complex,complex.__getattribute__,(inherited)
dict,dict.__getattribute__,(inherited)
dict_items,dict_items.__hash__,(inherited)
enumerate,enumerate.__getattribute__,(inherited)
filter,filter.__getattribute__,(inherited)
int,int.__getattribute__,(inherited)
list,list.__getattribute__,(inherited)
map,map.__getattribute__,(inherited)
memoryview,memoryview.__buffer__,
memoryview,memoryview.__getattribute__,(inherited)
memoryview,memoryview.__release_buffer__,
memoryview,memoryview._from_flags,
property,property.__getattribute__,(inherited)
range,range.__getattribute__,(inherited)
set,set.__getattribute__,(inherited)
slice,slice.__getattribute__,(inherited)
tuple,tuple.__getattribute__,(inherited)
zip,zip.__getattribute__,(inherited)
13 changes: 13 additions & 0 deletions _layouts/whats_left.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@
{% endfor %}
</ol>
</div>

<div class="section-title">What's left: Built-in Items</div>
{% assign items_by_builtin = site.data.whats_left.builtin_items | group_by: "builtin" %}
{% for group in items_by_builtin %}
<h4>{{ group.name }}</h4>
<div class="column-count-is-2">
<ol>
{% for item in group.items %}
<li class="word-wrap-anywhere"><code>{{ item.name }}</code>{% if item.is_inherited %} {{ item.is_inherited }}{% endif %}</li>
{% endfor %}
</ol>
</div>
{% endfor %}
</div>
39 changes: 39 additions & 0 deletions scripts/whats_left_builtin_items.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

It's a good practice to start your bash scripts with set -euo pipefail. This makes the script more robust by exiting on errors, treating unset variables as errors, and ensuring that a pipeline's exit status is the exit status of the last command to exit with a non-zero status.

Suggested change
#!/bin/bash
#!/bin/bash
set -euo pipefail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts/whats_left_modules.sh does not include this declaration.

set -euo pipefail

# paths where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

DATA_DIR="$PROJECT_ROOT/_data"
TEMP_FILE="$DATA_DIR/whats_left.temp"
OUTPUT_DIR="$DATA_DIR/whats_left"
OUTPUT_FILE="$OUTPUT_DIR/builtin_items.csv"

# create directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

# exit violently if the temp file does not exist
if [ ! -f "$TEMP_FILE" ]; then
echo "error: input file $TEMP_FILE not found" >&2
exit 1
fi

# generate the CSV file for builtin items from the temp file
awk -f - "$TEMP_FILE" > "$OUTPUT_FILE" <<'EOF'
BEGIN {
OFS=","
print "builtin,name,is_inherited"
}
/^# builtin items/ { in_section=1; next }
/^$/ { if (in_section) exit }
in_section {
split($1, a, ".")
rest = ""
idx = index($0, " ")
if (idx > 0) {
rest = substr($0, idx+1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current method of extracting the is_inherited part of the line is not robust against multiple spaces between the item name and the tag. For example, if a line were item (inherited), the value in the CSV would be (inherited) with a leading space. This can lead to inconsistent data.

A more robust approach is to take the substring from the first space onwards and then remove any leading spaces from it.

Suggested change
rest = substr($0, idx+1)
rest = substr($0, idx)
sub(/^ +/, "", rest)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-code-assist @coderabbitai The approach is dependent on the behavior of this line, which currently guarantees one period and at most one space: https://github.com/RustPython/RustPython/blob/5cad66cebfc62a7912197ae299ac13e8629c560d/whats_left.py#L477

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right, @fanninpm. My apologies for overlooking the specific guarantee provided by the Python script at whats_left.py#L477. Given that inherited_str is either an empty string or " (inherited)", the input to the awk script will indeed have at most one space before (inherited). In this scenario, the current awk logic rest = substr($0, idx+1) correctly extracts (inherited) without any leading spaces, making my previous suggestion unnecessary. Thank you for clarifying the input format!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the referenced line from the upstream RustPython repository
curl -s "https://raw.githubusercontent.com/RustPython/RustPython/5cad66cebfc62a7912197ae299ac13e8629c560d/whats_left.py" | sed -n '470,485p'

Length of output: 539


@fanninpm, you're absolutely right! I can confirm from the upstream code that line 477 uses:

print(f"{module}.{method}" + (f" {reason}" if reason else ""))

This guarantees the format is either module.method or module.method {reason} with exactly one space before the reason when present. Your current approach of using substr($0, idx+1) correctly extracts just the reason text by skipping that single guaranteed space.

Given this upstream format guarantee, the defensive handling of multiple spaces isn't necessary. Your implementation is appropriate and correctly relies on the documented behavior from the source.

}
print a[1], $1, rest
}
EOF