[CI] Improve automated checks (#2702)

* same stuff, but with some more spurious error supression

* fix issue in permissions found in this

* fix a few more spurious errors

* fix another issue

* semi-spurious error fixes

* .

* formatting

* move this to properly log

* distutils import + virtualenv

* more fixes
This commit is contained in:
Michael H
2019-06-02 13:42:58 -04:00
committed by Kowlin
parent 9116cd02e6
commit 16443c8cc0
20 changed files with 205 additions and 43 deletions

View File

@@ -27,7 +27,8 @@ def _is_submodule(parent, child):
return parent == child or child.startswith(parent + ".")
class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin):
# barely spurious warning caused by our intentional shadowing
class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin): # pylint: disable=no-member
"""Mixin for the main bot class.
This exists because `Red` inherits from `discord.AutoShardedClient`, which

View File

@@ -704,29 +704,35 @@ def mod():
class _IntKeyDict(Dict[int, _T]):
"""Dict subclass which throws KeyError when a non-int key is used."""
get: Callable
setdefault: Callable
def __getitem__(self, key: Any) -> _T:
if not isinstance(key, int):
raise TypeError("Keys must be of type `int`")
return super().__getitem__(key)
return super().__getitem__(key) # pylint: disable=no-member
def __setitem__(self, key: Any, value: _T) -> None:
if not isinstance(key, int):
raise TypeError("Keys must be of type `int`")
return super().__setitem__(key, value)
return super().__setitem__(key, value) # pylint: disable=no-member
class _RulesDict(Dict[Union[int, str], PermState]):
"""Dict subclass which throws a KeyError when an invalid key is used."""
get: Callable
setdefault: Callable
def __getitem__(self, key: Any) -> PermState:
if key != Requires.DEFAULT and not isinstance(key, int):
raise TypeError(f'Expected "{Requires.DEFAULT}" or int key, not "{key}"')
return super().__getitem__(key)
return super().__getitem__(key) # pylint: disable=no-member
def __setitem__(self, key: Any, value: PermState) -> None:
if key != Requires.DEFAULT and not isinstance(key, int):
raise TypeError(f'Expected "{Requires.DEFAULT}" or int key, not "{key}"')
return super().__setitem__(key, value)
return super().__setitem__(key, value) # pylint: disable=no-member
def _validate_perms_dict(perms: Dict[str, bool]) -> None:

View File

@@ -30,7 +30,7 @@ def get_latest_confs() -> Tuple["Config"]:
return tuple(ret)
class _ValueCtxManager(Awaitable[_T], AsyncContextManager[_T]):
class _ValueCtxManager(Awaitable[_T], AsyncContextManager[_T]): # pylint: disable=duplicate-bases
"""Context manager implementation of config values.
This class allows mutable config values to be both "get" and "set" from
@@ -1135,7 +1135,8 @@ class Config:
)
group = Group(identifier_data, defaults={}, driver=self.driver)
else:
group = self._get_base_group(*scopes)
cat, *scopes = scopes
group = self._get_base_group(cat, *scopes)
await group.clear()
async def clear_all(self):

View File

@@ -963,13 +963,13 @@ class Core(commands.Cog, CoreLogic):
"message", check=MessagePredicate.same_context(ctx), timeout=60
)
except asyncio.TimeoutError:
self.owner.reset_cooldown(ctx)
ctx.command.reset_cooldown(ctx)
await ctx.send(
_("The `{prefix}set owner` request has timed out.").format(prefix=ctx.prefix)
)
else:
if message.content.strip() == token:
self.owner.reset_cooldown(ctx)
ctx.command.reset_cooldown(ctx)
await ctx.bot.db.owner.set(ctx.author.id)
ctx.bot.owner_id = ctx.author.id
await ctx.send(_("You have been set as owner."))

View File

@@ -35,7 +35,7 @@ basic_config_default = {"DATA_PATH": None, "COG_PATH_APPEND": "cogs", "CORE_PATH
config_dir = None
appdir = appdirs.AppDirs("Red-DiscordBot")
if sys.platform == "linux":
if 0 < os.getuid() < 1000:
if 0 < os.getuid() < 1000: # pylint: disable=no-member
config_dir = Path(appdir.site_data_dir)
if not config_dir:
config_dir = Path(appdir.user_config_dir)

View File

@@ -57,7 +57,7 @@ class JsonIO:
tmp_path.replace(self.path)
# pylint: disable=E1101
# pylint: disable=no-member
try:
fd = os.open(self.path.parent, os.O_DIRECTORY)
os.fsync(fd)

View File

@@ -69,7 +69,8 @@ def safe_delete(pth: Path):
shutil.rmtree(str(pth), ignore_errors=True)
class AsyncFilter(AsyncIterator[_T], Awaitable[List[_T]]):
# https://github.com/PyCQA/pylint/issues/2717
class AsyncFilter(AsyncIterator[_T], Awaitable[List[_T]]): # pylint: disable=duplicate-bases
"""Class returned by `async_filter`. See that function for details.
We don't recommend instantiating this class directly.
@@ -112,6 +113,9 @@ class AsyncFilter(AsyncIterator[_T], Awaitable[List[_T]]):
async def __flatten(self) -> List[_T]:
return [item async for item in self]
def __aiter__(self):
return self
def __await__(self):
# Simply return the generator filled into a list
return self.__flatten().__await__()