r/Python • • Mar 10 '24

Discussion Github Copilot Lies to me

My first attempt to get some help from Github Copilot:

Me: write a match case statement in python to match the first character of a string is a semicolon

Copilot: Python doesn't have a built-in match or case statement like some other languages (e.g., JavaScript, Swift, Rust). However, you can achieve similar functionality using...

Strangely, it finally gave me an answer when I made a small change to my prompt:

Me: write a match statement in python to match the first character of a string is a semicolon

Copilot: Python 3.10 introduces the structural pattern matching in the form of the match statement. Here's how you can use it to check if the first character of a string is a semicolon:...

I almost gave up after the first response that was blatantly false. Fortunately I something that looks like reasonable syntax...but then I haven't tried it yet, so that might be a lie, too.

0 Upvotes

67 comments sorted by

View all comments

3

u/maxinstuff Mar 10 '24

Literally had this just yesterday (with Rust though) - GPT straight made up a method that didn’t exist (though if it did it would have solved my problem).

Wasted at least 5 minutes of my time.

I’d still say GPT is still a net time-saver, as long as it’s used for the right things.

3

u/ToddBradley Mar 10 '24

This issue - hallucinating APIs that don't exist - is my biggest complaint. The basic IDE autocomplete does better. I use Copilot every day but I gotta double check everything.

2

u/wakkawakkaaaa Mar 10 '24

Same here. And copilot inline suggestions are taken by default with tab instead of the VScode basic autocomplete... It sucks for python and its commonly used libraries.

My experience with copilot was much better with typescript though. I suspect its because typescript is much younger as compared to python and related libraries which lived through more major updates.