DidYouMean-Python
DidYouMean-Python copied to clipboard
More suggestions
Maybe things from https://twitter.com/DrapsTV/status/660657599210266624 can be reused (maybe not).
A few ideas from http://migrateup.com/main-difference-python-3/ are interesting too.
http://www.oreilly.com/programming/free/how-to-make-mistakes-in-python.csp /http://www.oreilly.com/programming/free/files/how-to-make-mistakes-in-python.pdf
Probably worth re-reading http://stupidpythonideas.blogspot.fr/2015/05/if-you-dont-like-exceptions-you-dont.html ( and http://stupidpythonideas.blogspot.fr/2015/12/how-lookup-works.html ) when I have more time.
https://github.com/mdipierro/autoinstaller : interesting idea. I'll try to understand the code and see if I can reuse ideas out of it.
Also, it could be nice to make things usable with the -m option ( http://python-packaging.readthedocs.org/en/latest/command-line-scripts.html / https://www.reddit.com/r/Python/comments/42u5dm/how_to_structure_a_module_that_is_intended_to_be/ ).
https://github.com/bndr/pipreqs/blob/master/pipreqs/pipreqs.py
Principle of Least Astonishment and Python : http://lucumr.pocoo.org/2011/7/9/python-and-pola/ .
A few suggestions might make sense.
Confusing/interesting error messages here : https://www.reddit.com/r/Python/comments/4ivd2k/what_is_your_favorite_python_error_message/
https://github.com/asweigart/pydidyoumean
I've just discovered the change about literal octals in Python 3. Might be interesting to have a suggestion.
https://twitter.com/raymondh/status/772957699478663169 "#python tip: What Python says: "TypeError: 'method' object is not subscriptable" What it means: "Use parentheses instead of square brackets""
https://twitter.com/raymondh/status/773224135409360896 "What #Python says: TypeError: 'Tk' object cannot be interpreted as an integer What it means: class 'Tk' does not have an index method"
http://stackoverflow.com/questions/38147923/mixing-datetime-strptime-arguments/38215307 pretty common error: mixing argument of strptime.
https://twitter.com/brandon_rhodes/status/781234730091941888
SyntaxError: if a = b: and if a == b
https://twitter.com/cfbolz/status/783313503230844929 .
The whole twitter thread is interesting with links such as:
https://www.researchgate.net/publication/307088989_Some_Trouble_with_Transparency_An_Analysis_of_Student_Errors_with_Object-oriented_Python
https://mail.python.org/pipermail/python-ideas/2016-October/042672.html
https://github.com/ipython/ipython/pull/9073/files
Also, the corresponding commit is:
https://bitbucket.org/pypy/pypy/commits/e664458f25d07bbc8378161dcd8973df6a701b96
(includes nice tests)
http://inventwithpython.com/blog/2012/07/09/16-common-python-runtime-errors/
>>> 3.5 ^ 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for ^: 'float' and 'int'
>>> 3.5 ** 2
12.25
>>> raise NotImplemented
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exceptions must be old-style classes or derived from BaseException, not NotImplementedType
A fuzzy match on the actual subclasses of BaseException could be nice :)
TypeError: unhashable instance
Maybe suggest how to make the instance hashable (on custom classes), maybe suggest hashable types (frozenset, tuple, etc).
https://mail.python.org/pipermail/python-ideas/2016-November/043848.html https://mail.python.org/pipermail/python-ideas/2016-December/043910.html
RuntimeError: dictionary changed size during iteration
Maybe suggest ideas from : http://stackoverflow.com/questions/11941817/how-to-avoid-runtimeerror-dictionary-changed-size-during-iteration-error
http://stackoverflow.com/questions/19234598/typeerror-str-object-cannot-be-interpreted-as-an-integer
http://stackoverflow.com/questions/28036309/typeerror-list-object-cannot-be-interpreted-as-an-integer
https://mail.python.org/pipermail/python-checkins/2015-October/139263.html
This is an interesting issue and might deserve some suggestion : http://stackoverflow.com/questions/4545661/unicodedecodeerror-when-redirecting-to-file
TypeError: can only concatenate list (not "dict_keys") to list
TypeError: argument to reversed() must be a sequence
http://stackoverflow.com/questions/41388606/python-3-6-vs-3-5-typeerror-message-on-string-concatenation
I got this issue : http://stackoverflow.com/questions/24463202/typeerror-get-takes-no-keyword-arguments . Maybe suggesting position arguments and explaining that C-level API is exception to the usual rule is a good idea.
http://sametmax.com/quelques-erreurs-tordues-et-leurs-solutions-en-python/
http://darkf.github.io/posts/problems-i-have-with-python.html
Idea: detection (?) and suggestion for circular import.
https://fr.reddit.com/r/Python/comments/5qxhcu/could_you_take_a_look_at_my_first_ever_python/?st=iyjta9cc&sh=5cd2c314
https://github.com/bndr/pycycle
https://docs.python.org/3/faq/programming.html#how-can-i-have-modules-that-mutually-import-each-other
https://docs.python.org/3/faq/programming.html#what-are-the-best-practices-for-using-import-in-a-module
Idea: reuse _moved_attributes from https://github.com/benjaminp/six/blob/master/six.py (with proper attribution).
Idea: use gc.get_objects() for various purposes (get_func_by_name, get_type_by_name, etc).
https://twitter.com/sam_et_max/status/836551598054731776 https://twitter.com/sam_et_max/status/836551787058454529
"TypeError: 'generator' object is not subscriptable" -> itertools.islice(my_generator, 5)
Set.remove keyerror set.discard
Suggest using PYTHONIOENCODING n case of Encode/Decode error (when relevant - whatever it means, not always)
http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html#the-name-shadowing-trap
TypeError: Cannot create a consistent method resolution... http://stackoverflow.com/questions/29214888/typeerror-cannot-create-a-consistent-method-resolution-order-mro
https://mail.python.org/pipermail/python-ideas/2017-June/046025.html https://mail.python.org/pipermail/python-ideas/2017-June/045954.html
Interesting thing already done : https://twitter.com/DRMacIver/status/912812300125577216?s=03 .
>>> sum(["a", "b", "c"], '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sum() can't sum strings [use ''.join(seq) instead]
>>> set([42])[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'set' object does not support indexing
Maybe suggest pop ?
>>> del s[42]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'set' object doesn't support item deletion
>>> s.remove(42)
>>> d = {43: 'x'}
>>> d.remove(43)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'remove'
>>> del d[43]
(Also discard)
https://mail.python.org/pipermail/python-ideas/2017-July/046318.html
https://twitter.com/DRMacIver/status/949956253358452736
https://blog.lerner.co.il/favorite-terrible-python-error-message/
See also: https://bugs.python.org/issue31506
Add tests for walrus operator
Add suggestion for keyerror. I thought this was tackled already but apparently no
https://realpython.com/python-keyerror/
Positional only arguments
https://inventwithpython.com/blog/2019/08/15/python-error-messages-gotta-catch-em-all/
KeyError on del on a dict. Should call pop ?
https://twitter.com/cfbolz/status/1168979340601831424?s=19
https://bitbucket.org/pypy/pypy/commits/c0b2526268ab96a0b3caa7bdafa2cf0309a73a20 https://bitbucket.org/pypy/pypy/commits/de78bcdc0fad5293211864bfabf3ad61e8780d6a https://bitbucket.org/pypy/pypy/commits/8cebeebbf0a7fb6c61aa65183f53392c68967fb3
It looks like cfbolz really like to improve error messages: https://github.com/cfbolz/syntaxerrors . To be added to README eventually.
https://twitter.com/AlSweigart/status/1186397310374203392?s=19 I can't remember if this would be handled properly