| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 804bc80 commit fa45526
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1382,7 +1382,7 @@ def __contains__(self, attr: object) -> bool: | |||
| 1382 | 1382 | ||
| 1383 | 1383 | # Otherwise make a full name search. | |
| 1384 | 1384 | try: | |
| 1385 | - getattr(self, cast(str, attr)) # Use cast to silence mypy. | ||
| 1385 | + self.__getattr__(cast(str, attr)) # Use cast to silence mypy. | ||
| 1386 | 1386 | return True | |
| 1387 | 1387 | except (AttributeError, TypeError): | |
| 1388 | 1388 | return False | |
@@ -1394,7 +1394,7 @@ def __getattr__(self, attr: str) -> T_IterableObj: | |||
| 1394 | 1394 | if getattr(item, self._id_attr) == attr: | |
| 1395 | 1395 | return item | |
| 1396 | 1396 | # END for each item | |
| 1397 | - return list.__getattribute__(self, attr) | ||
| 1397 | + raise AttributeError(f"No item found with id {attr}") | ||
| 1398 | 1398 | ||
| 1399 | 1399 | def __getitem__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] | |
| 1400 | 1400 | self, index: Union[SupportsIndex, int, slice, str] | |
@@ -1405,7 +1405,7 @@ def __getitem__( # type: ignore[override] # pyright: ignore[reportIncompatible | |||
| 1405 | 1405 | raise ValueError("Index should be an int or str") | |
| 1406 | 1406 | else: | |
| 1407 | 1407 | try: | |
| 1408 | - return getattr(self, cast(str, index)) | ||
| 1408 | + return self.__getattr__(cast(str, index)) | ||
| 1409 | 1409 | except AttributeError as e: | |
| 1410 | 1410 | raise IndexError(f"No item found with id {self._prefix}{index}") from e | |
| 1411 | 1411 | # END handle getattr | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -862,3 +862,23 @@ def test_mode_str_to_int_accepts_bytes(): | |||
| 862 | 862 | assert mode_str_to_int(b"100644") == 0o100644 | |
| 863 | 863 | assert mode_str_to_int("644") == 0o644 | |
| 864 | 864 | assert mode_str_to_int(b"120000") == 0o120000 | |
| 865 | + | ||
| 866 | + | ||
| 867 | + @pytest.mark.parametrize("name", ["sort", "count", "append", "_prefix", "__class__", "ordinary"]) | ||
| 868 | + @pytest.mark.parametrize("prefix", ["", "refs/"]) | ||
| 869 | + def test_iterable_list_name_lookup_ignores_list_attributes(name, prefix): | ||
| 870 | + values = IterableList("name", prefix) | ||
| 871 | + member = _Member(prefix + name) | ||
| 872 | + values.append(member) | ||
| 873 | + | ||
| 874 | + assert values[name] is member | ||
| 875 | + assert name in values | ||
| 876 | + assert member in values | ||
| 877 | + assert values[0] is member | ||
| 878 | + assert callable(values.append) | ||
| 879 | + assert callable(values.sort) | ||
| 880 | + | ||
| 881 | + del values[name] | ||
| 882 | + assert name not in values | ||
| 883 | + with pytest.raises(IndexError, match="No item found with id"): | ||
| 884 | + values[name] | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments