Skip to content

Commit

Permalink
Replace pylint with flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
basicthinker committed Apr 23, 2023
1 parent 8a90c05 commit 5d3f457
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
pip install pylint pytest
pip install flake8 pytest
- run:
name: Run pylint
name: Run flake8
command: |
. venv/bin/activate
export PYTHONPATH=.
pylint devchat
flake8 devchat
- run:
name: Run pytest
command: |
Expand Down
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 100
7 changes: 0 additions & 7 deletions .pylintrc

This file was deleted.

1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.flake8Args": ["--max-line-length=100"]
}
2 changes: 2 additions & 0 deletions devchat/chat/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .chat import Chat

__all__ = ['Chat']
14 changes: 13 additions & 1 deletion tests/test_message.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,64 @@
import pytest
from devchat.message import Message


def test_valid_message_creation():
message = Message(role="user", content="Hello, World!")
assert message.role == "user"
assert message.content == "Hello, World!"
assert message.name is None


def test_valid_message():
message = Message("user", "Hello, World!", "John_Doe")
assert message.to_dict() == {"role": "user", "content": "Hello, World!", "name": "John_Doe"}


def test_invalid_role():
with pytest.raises(ValueError):
Message("invalid_role", "Hello, World!")


def test_none_content():
message = Message(role="user", content=None)
assert message.content is None


def test_empty_content():
with pytest.raises(ValueError):
Message("user", "")


def test_blank_content():
with pytest.raises(ValueError):
Message("user", " ")


def test_invalid_name():
with pytest.raises(ValueError):
Message("user", "Hello, World!", "Invalid@Name")


def test_empty_name():
with pytest.raises(ValueError):
Message("user", "Hello, World!", "")


def test_blank_name():
with pytest.raises(ValueError):
Message("user", "Hello, World!", " ")


def test_tab_content():
with pytest.raises(ValueError):
Message(role="user", content="\t")


def test_none_name():
message = Message("user", "Hello, World!", None)
assert message.to_dict() == {"role": "user", "content": "Hello, World!"}


def test_from_dict():
message_data = {
"content": "Welcome to the chat.",
Expand All @@ -57,6 +69,7 @@ def test_from_dict():
assert message.content == "Welcome to the chat."
assert message.name is None


def test_from_dict_with_name():
message_data = {
"content": "Hello, Assistant!",
Expand All @@ -67,4 +80,3 @@ def test_from_dict_with_name():
assert message.role == "user"
assert message.content == "Hello, Assistant!"
assert message.name == "JohnDoe"

0 comments on commit 5d3f457

Please sign in to comment.