I have the following code that accesses a website and stops browser notifications:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
option = webdriver.ChromeOptions()
***option.add_experimental_option("excludeSwitches", ["enable-automation"])
option.add_experimental_option('useAutomationExtension', False)
option.add_argument("--disable-infobars")
option.add_argument("start-maximized")
option.add_argument("--disable-extensions")
option.add_experimental_option("detach", True)
option.add_experimental_option("prefs", {
"profile.default_content_setting_values.notifications": 2
})
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=option)
driver.get("https://www.reddit.com/r/AskReddit/")
The code runs, but my IDE (Visual Studio Code) says that from *** onwards the "Code is unreachable Pylance". Does anyone know how I could fix this? It's annoying since it grays out everything after the *** line. Thank you.
Visual representation of what I'm seeing:

With warning:

Solution:
It's a bug. Update to the most recent version of selenium to fix the issue.
I found this out by finding the same issue also being discussed here: https://github.com/microsoft/pylance-release/issues/2807
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With