-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
First of all, amazing work!
Any plans to incorporate static typing support with mypy?
Beta Was this translation helpful? Give feedback.
All reactions
Hello @feslima! Thank you, and welcome to SeleniumBase discussions!
SeleniumBase has its own system of type verification, such as demonstrated in the below code snippet, which processes all inputs of selectors for SeleniumBase methods:
... _type = type(selector) # First make sure the selector is a string not_string = False if not python3: if _type is not str and _type is not unicode: # noqa: F821 not_string = True else: if _type is not str: not_string = True if not_string: msg = "Expecting a selector of type: \"<class 'str'>\" (string)!" raise Exception('Invalid selector type: "%s"\n%s' % (_type, msg)) ...
With all these in place, it's not necessary to ad...
Replies: 1 comment 2 replies
-
Hello @feslima! Thank you, and welcome to SeleniumBase discussions!
SeleniumBase has its own system of type verification, such as demonstrated in the below code snippet, which processes all inputs of selectors for SeleniumBase methods:
... _type = type(selector) # First make sure the selector is a string not_string = False if not python3: if _type is not str and _type is not unicode: # noqa: F821 not_string = True else: if _type is not str: not_string = True if not_string: msg = "Expecting a selector of type: \"<class 'str'>\" (string)!" raise Exception('Invalid selector type: "%s"\n%s' % (_type, msg)) ...
With all these in place, it's not necessary to add in additional type handling. And it wouldn't be possible either because SeleniumBase supports Python versions 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10
(whereas mypy doesn't support the earliest versions listed there).
However, if people desire to add in support to their own programs that use SeleniumBase (and they have a newer version of Python), then they are welcome to add in typing support to their own code.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for enlightenment @mdmintz.
One more question: Is it possible to set these configurations via a pyproject.toml
file like mypy does? Or even a specific config file (e.g. .ini, .yaml, etc.) for SeleniumBase? I couldn't find anything mentioned in the docs.
Thanks again for the attention.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi @feslima, yes, you can use a pytest.ini
file for that, eg: https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini
I talk about it in the main ReadMe.md file:
🔵 When running tests with pytest, you'll want a copy of pytest.ini in your root folders. When running tests with nosetests, you'll want a copy of setup.cfg in your root folders. These files specify default configuration details for tests. Folders should also include a blank __init__.py
file, which allows your tests to import files from that folder.
Beta Was this translation helpful? Give feedback.