Skip to content
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

[Feature] Contributing guidelines & syntax formatting-checkers #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ dmypy.json

# vscode
.vscode/

# asdf
.tool-versions
80 changes: 80 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
default_language_version:
python: python3

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: master
hooks:
- id: check-merge-conflict
- id: check-added-large-files
args: ['--maxkb=30000']
- id: check-executables-have-shebangs
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3.7
- repo: local
hooks:
- id: flake8
name: flake8
description: Python style guide enforcement.
entry: flake8
args: [
"--config=setup.cfg",
"--ignore=E501,PD011,F403,F405,W503,E231,VNE001"
]
additional_dependencies: [
flake8,
flake8-2020, # flake8 plugin which checks for misuse of `sys.version` or `sys.version_info`
flake8-blind-except, # A flake8 extension that checks for blind except: statements
flake8-builtins, # Check for python builtins being used as variables or parameters.
flake8-comprehensions, # It helps you write better list/set/dict comprehensions.
dlint, # Dlint is a tool for encouraging best coding practices and helping ensure we're writing secure Python code.
flake8-pytest, # pytest assert checker plugin for flake8
flake8-tabs, # Tab (or Spaces) indentation style checker for flake8
]
language: python
language_version: python3.7
types: [python]
require_serial: true
- id: autoflake
name: autoflake
description: remove unused imports
entry: autoflake
args: [
"--in-place",
"--remove-unused-variables"
]
language: python
language_version: python3.7
types: [python]
require_serial: true
additional_dependencies: [autoflake]
- id: isort
name: isort
description: Automatically sort imports.
entry: isort
args: [
"--recursive",
]
language: python
language_version: python3.7
types: [python]
require_serial: true
additional_dependencies: [isort]
- id: pytest
name: Run Pytest
description: Run Python unit-tests
entry: pytest
language: python
types: [python]
language_version: python3.7
require_serial: true
stages: [push]
additional_dependencies: [
pytest,
pytest-cov,
pytest-mock
]
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contributing
We follow the "fork-and-pull" Git workflow.

1. Fork the *ColabCode* repo from `master` branch
2. Clone the fork locally
3. Create a branch for local development
4. When done making changes, make sure that your changes pass [flake8](https://pypi.org/project/flake8/). Also ensure, that your code is formatted using [black](https://github.com/psf/black).
5. Commit changes to your own branch and push them to your fork
6. Submit a Pull request for review

## Coding Style
The codebase uses
* [black](https://github.com/psf/black) for code formatting.
* [flake8](https://pypi.org/project/flake8/) for code checking

Install dependencies from *requirements.txt*.
```
pip install -r requirements.txt
```

Run black -
```python
black .
```

Before commiting -
```bash
pre-commit install
```

All your changes will be tested. Check `.pre-commit-config.yaml`

25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@

Run code server on Google Colab or Kaggle Notebooks

- install colabcode: `pip install colabcode`
- import colabcode: `from colabcode import ColabCode`
- run: `ColabCode(port=10000, password="abhishek")`
- you can also run it with any password or port :)
## Getting Started
Install colabcode
```bash
pip install colabcode
```
Import colabcode
```python
from colabcode import ColabCode
```
Run colabcode
```
ColabCode(port=10000, password="myawesome password")
```
You can also run it with any password or port :)

See an example in [this video tutorial](https://www.youtube.com/watch?v=7kTbM3D02jU).
## Relevant Sources
* Checkout Abhishek's YouTube video [here](https://www.youtube.com/watch?v=7kTbM3D02jU)
* [VSCode on Google Colab](https://amitness.com/vscode-on-colab/) article by Amit Chaudhary

## Contributing
Kindly refer to [CONTRIBUTING.md](CONTRIBUTING.md)
2 changes: 2 additions & 0 deletions colabcode/code.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import subprocess
from pyngrok import ngrok

try:
from google.colab import drive

colab_env = True
except ImportError:
colab_env = False
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pyngrok=4.1.11
pyngrok==4.1.11
pre-commit
flake8
black