New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code marked unreachable after start_transaction() from mysql.connector #940
Comments
@abstractmethod
def rollback(self):
"""Rollback current transaction"""
pass
def start_transaction(self, consistent_snapshot=False,
isolation_level=None, readonly=None):
"""Start a transaction
This method explicitly starts a transaction sending the
START TRANSACTION statement to the MySQL server. You can optionally
set whether there should be a consistent snapshot, which
isolation level you need or which access mode i.e. READ ONLY or
READ WRITE.
For example, to start a transaction with isolation level SERIALIZABLE,
you would do the following:
>>> cnx = mysql.connector.connect(..)
>>> cnx.start_transaction(isolation_level='SERIALIZABLE')
Raises ProgrammingError when a transaction is already in progress
and when ValueError when isolation_level specifies an Unknown
level.
"""
if self.in_transaction:
raise errors.ProgrammingError("Transaction already in progress")
if isolation_level:
level = isolation_level.strip().replace('-', ' ').upper()
levels = ['READ UNCOMMITTED', 'READ COMMITTED', 'REPEATABLE READ',
'SERIALIZABLE']
if level not in levels:
raise ValueError(
'Unknown isolation level "{0}"'.format(isolation_level))
self._execute_query(
"SET TRANSACTION ISOLATION LEVEL {0}".format(level))
if readonly is not None:
if self._server_version < (5, 6, 5):
raise ValueError(
"MySQL server version {0} does not support "
"this feature".format(self._server_version))
if readonly:
access_mode = 'READ ONLY'
else:
access_mode = 'READ WRITE'
self._execute_query(
"SET TRANSACTION {0}".format(access_mode))
query = "START TRANSACTION"
if consistent_snapshot:
query += " WITH CONSISTENT SNAPSHOT"
self.cmd_query(query) |
When you hover I'm thinking that this does need an annotation, e.g. |
Answer to your question: More important: I cannot reproduce the behavior anymore. Between my last (failing) test an now I just put my PC to sleep and came back now to see that it works. The best explanation I have is that an update was prepared. I don't know how it was effective before I restarted VS Code but I guess we won't find out. Timeline what happened:
Maybe my lengthy explanation helps you if you see similar cases. From my side this issue can be closed. |
Oh and thank you for your very quick reply! |
Did VS Code update you to a newer version of Pylance, by chance? The issue is that it was inferred as |
Looks like it did. I have two versions in my extensions folder. ls -lah ~/.vscode-server/extensions/
...
drwxr-xr-x 4 axx axx 4.0K Feb 11 18:04 ms-python.vscode-pylance-2021.2.1
drwxr-xr-x 4 axx axx 4.0K Feb 11 20:30 ms-python.vscode-pylance-2021.2.2
... The file from 20:30 obviously comes from the update I did half an hour ago. The file from 18:04 was created in the middle of my work - roughly around the time I saw the issue. |
Directly after writing my last comment:
After restarting VS Code (No warning that a restart is needed was shown)
I guess we can be pretty sure that my issue was somehow related to updates. |
Now the older version in the extensions folder is gone. It looks like I got at least three updates for the Language Server today. Thinking a bit more about the root cause I got annother idea: FYI: I will be afk until tomorrow. |
I'm going to close this as I think you said you couldn't reproduce it anymore (and it's been a good month). If it reappears, we can reopen and take a look. |
Environment data
Expected behaviour
Do not mark code following
start_transaction()
as unreachableActual behaviour
Code following
start_transaction()
is marked as unreachableLogs
Code Snippet / Additional information
This issue was mentioned by @QuestofIranon in a comment on #31 and he/she was asked to create a separate ticket but I could not find one.
The text was updated successfully, but these errors were encountered: