Visual Studio Code Integration
Once installed, Tabnine adds its own bar to the interface along with additional options at the bottom. Unlike BlackboxAI, Tabnine allows you to select from various models for its chat interface. For example, you can opt for models such as Claude 3.5 Sonnet (ideal for programming), GPT 4.0, CodeStroll (available on Hugging Face and runnable locally), Command R+, Tabnine Protected, and Tabnine Plus Mistral. Models labeled as “private” or “protected” are designed to run within your private network, ensuring that your proprietary code remains confidential and is not used for training.
Creating a “Hello, World!” Python Application
Scaffolding with Tabnine
To demonstrate Tabnine’s capabilities, we will scaffold a basic “Hello, World!” Python project. Instead of merely creating a script, we’ll instruct Tabnine to generate a fully structured project using the term “scaffold” to enforce best practices. When you select a model—for instance, GPT 4.0—a legal terms popup will appear that you must acknowledge before proceeding.
- A project directory
- A virtual environment
- A structured project hierarchy
- A README file
- A .gitignore file
- A LICENSE file
src/main.py:
Even if your project only uses base libraries, setting up a virtual environment and a proper project structure is a best practice for ensuring maintainability and scalability.
Setting Up the Project
Follow these steps in your terminal to set up the project structure:src/main.py in Visual Studio Code and paste the following:
Enhancing Code Quality: Comments and Tests
Tabnine is also capable of guiding you to add inline code comments for better documentation. For example, the code can be revised as follows:tests/main.test.py, with the following unit test:
Adding descriptive comments and tests early in the development process helps maintain code quality and facilitates future enhancements.
Code Explanation and Documentation
If you ask Tabnine for an explanation, it might provide this breakdown:- The
defkeyword is used to define themainfunction, which serves as the entry point. - The line
if __name__ == "__main__":ensures that the script is executed only when run directly. - Proper code documentation is essential for maintaining clarity and easing future modifications.