Skip to content

Commit

Permalink
Merge pull request #5 from yuji38kwmt/update-slackclient
Browse files Browse the repository at this point in the history
updaate slackclient 2.5 -> 2.6
  • Loading branch information
yuji38kwmt authored May 24, 2020
2 parents c043501 + 321bce4 commit 53896e2
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 100 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ install:
- poetry install

script:
- poetry run mypy slack_primitive_cli
- poetry run flake8 slack_primitive_cli
branches:
only:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ format:
poetry run isort --verbose --recursive ${TARGET}

lint:
poetry run mypy ${TARGET}
poetry run flake8 ${TARGET}

publish:
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True
228 changes: 155 additions & 73 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "slack-primitive-cli"
version = "0.1.1"
version = "0.1.2"
description = "Primitive Slack CLI"
authors = ["yuji38kwmt <yuji38kwmt@gmail.com>"]
maintainers = ["yuji38kwmt <yuji38kwmt@gmail.com>"]
Expand All @@ -23,7 +23,7 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.6"
slackclient = "^2"
slackclient = "^2.6"
click = "^7"
click-option-group = "*"

Expand All @@ -32,14 +32,11 @@ flake8 = "*"
autoflake = "*"
isort = "*"
black = {version = "^19.10b0", allow-prereleases = true}
mypy = "*"

[tool.poetry.scripts]
slackcli = "slack_primitive_cli.__main__:cli"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.black]
line-length = 120

Expand All @@ -52,3 +49,7 @@ multi_line_output=3
include_trailing_comma=true
force_grid_wrap=0
use_parentheses=true
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

2 changes: 1 addition & 1 deletion slack_primitive_cli/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.1"
__version__ = "0.1.2"
30 changes: 10 additions & 20 deletions slack_primitive_cli/command/files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import Any, Optional

import click
import slack
Expand All @@ -23,25 +22,16 @@ def upload(token, channels, file, content, filename, filetype, initial_comment,
if filename is None and file is not None:
filename = os.path.basename(file)

def _update_kwargs(key: str, value: Optional[Any]):
if value is not None:
kwargs[key] = value

kwargs = dict(channels=channels)
_update_kwargs("file", file)
_update_kwargs("content", content)
_update_kwargs("filename", filename)
_update_kwargs("filetype", filetype)
_update_kwargs("initial_comment", initial_comment)
_update_kwargs("thread_ts", thread_ts)
_update_kwargs("title", title)

# Noneの引数を渡すと、以下のエラーが発生するため、Noneの引数は`files_upload`メソッドに渡さないようにする
# TypeError: Can not serialize value type: <class 'NoneType'>
if title is not None:
kwargs["title"] = title

response = client.files_upload(**kwargs)
response = client.files_upload(
channels=channels,
file=file,
content=content,
filename=filename,
filetype=filetype,
initial_comment=initial_comment,
thread_ts=thread_ts,
title=title,
)
print(response)
return response

Expand Down

0 comments on commit 53896e2

Please sign in to comment.