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

Upgrade requirements #796

Merged
merged 3 commits into from
Oct 25, 2023
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/zulip-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.7"
python-version: "3.8"

- name: Install dependencies
run: tools/provision --force
Expand All @@ -32,7 +32,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
crayons
twine
black==23.3.0
black~=23.10.1
isort
flake8
mock
Expand All @@ -9,8 +9,8 @@ pytest-cov
-e ./zulip
-e ./zulip_bots
-e ./zulip_botserver
-e git+https://github.com/zulip/zulint@14e3974001bf8442a6a3486125865660f1f2eb68#egg=zulint==1.0.0
mypy==0.910
-e git+https://github.com/zulip/zulint@85de0cbadbba3f498deba32f861bb9a478faa3b4#egg=zulint==1.0.0
mypy==1.6.1
types-python-dateutil
types-pytz
types-requests
Expand Down
31 changes: 4 additions & 27 deletions tools/custom_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,29 @@

whitespace_rules: List[Rule] = [
# This linter should be first since bash_rules depends on it.
{"pattern": r"\s+$", "strip": "\n", "description": "Fix trailing whitespace"},
{"pattern": "\t", "strip": "\n", "description": "Fix tab-based whitespace"},
{"pattern": r"[\t ]+$", "description": "Fix trailing whitespace"},
{"pattern": r"\t", "description": "Fix tab-based whitespace"},
]

markdown_whitespace_rules = list(
rule for rule in whitespace_rules if rule["pattern"] != r"\s+$"
rule for rule in whitespace_rules if rule["pattern"] != r"[\t ]+$"
) + [
# Two spaces trailing a line with other content is okay--it's a markdown line break.
# This rule finds one space trailing a non-space, three or more trailing spaces, and
# spaces on an empty line.
{
"pattern": r"((?<!\s)\s$)|(\s\s\s+$)|(^\s+$)",
"strip": "\n",
"pattern": r"((?<![\t ])[\t ]$)|([\t ][\t ][\t ]+$)|(^[\t ]+$)",
"description": "Fix trailing whitespace",
},
{
"pattern": r"^#+[A-Za-z0-9]",
"strip": "\n",
"description": "Missing space after # in heading",
},
]

python_rules = RuleList(
langs=["py"],
rules=[
{"pattern": r'".*"%\([a-z_].*\)?$', "description": 'Missing space around "%"'},
{"pattern": r"'.*'%\([a-z_].*\)?$", "description": 'Missing space around "%"'},
# This rule is constructed with + to avoid triggering on itself
{"pattern": r" =" + r'[^ =>~"]', "description": 'Missing whitespace after "="'},
{"pattern": r'":\w[^"]*$', "description": 'Missing whitespace after ":"'},
{"pattern": r"':\w[^']*$", "description": 'Missing whitespace after ":"'},
{"pattern": r"^\s+[#]\w", "strip": "\n", "description": 'Missing whitespace after "#"'},
{
"pattern": r"assertEquals[(]",
"description": "Use assertEqual, not assertEquals (which is deprecated).",
Expand All @@ -46,13 +37,6 @@
"good_lines": ["def foo (self):"],
"bad_lines": ["def foo(self: Any):"],
},
{"pattern": r"== None", "description": "Use `is None` to check whether something is None"},
{"pattern": r"type:[(]", "description": 'Missing whitespace after ":" in type annotation'},
{"pattern": r"# type [(]", "description": "Missing : after type in type annotation"},
{"pattern": r"#type", "description": 'Missing whitespace after "#" in type annotation'},
{"pattern": r"if[(]", "description": "Missing space between if and ("},
{"pattern": r", [)]", "description": 'Unnecessary whitespace between "," and ")"'},
{"pattern": r"% [(]", "description": 'Unnecessary whitespace between "%" and "("'},
# This next check could have false positives, but it seems pretty
# rare; if we find any, they can be added to the exclude list for
# this rule.
Expand Down Expand Up @@ -97,7 +81,6 @@
},
*whitespace_rules,
],
max_length=140,
)

bash_rules = RuleList(
Expand Down Expand Up @@ -145,10 +128,6 @@
},
]

markdown_docs_length_exclude = {
"zulip_bots/zulip_bots/bots/converter/doc.md",
}

markdown_rules = RuleList(
langs=["md"],
rules=[
Expand All @@ -159,8 +138,6 @@
"description": "Linkified markdown URLs should use cleaner <http://example.com> syntax.",
},
],
max_length=120,
length_exclude=markdown_docs_length_exclude,
)

txt_rules = RuleList(
Expand Down
2 changes: 1 addition & 1 deletion zulip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The [Zulip API](https://zulip.com/api) Python bindings require the
following dependencies:

* **Python (version >= 3.7)**
* **Python (version >= 3.8)**
* requests (version >= 0.12.1)

**Note**: If you'd like to use the Zulip bindings with Python 2, we
Expand Down
3 changes: 2 additions & 1 deletion zulip/integrations/jabber/jabber_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import sys
import traceback
from types import FrameType
from typing import Optional

from zulip import RandomExponentialBackoff


def die(signal: int, frame: FrameType) -> None:
def die(signal: int, frame: Optional[FrameType]) -> None:
"""We actually want to exit, so run os._exit (so as not to be caught and restarted)"""
os._exit(1)

Expand Down
6 changes: 3 additions & 3 deletions zulip/integrations/zephyr/zephyr_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import subprocess
import sys
import traceback
from types import FrameType
from typing import Optional

sys.path[:0] = [os.path.dirname(__file__)]
from zephyr_mirror_backend import parse_args

(options, args) = parse_args()

from types import FrameType


def die(signal: int, frame: FrameType) -> None:
def die(signal: int, frame: Optional[FrameType]) -> None:
# We actually want to exit, so run os._exit (so as not to be caught and restarted)
os._exit(1)

Expand Down
2 changes: 1 addition & 1 deletion zulip/integrations/zephyr/zephyr_mirror_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ def parse_args() -> Tuple[optparse.Values, List[str]]:
return parser.parse_args()


def die_gracefully(signal: int, frame: FrameType) -> None:
def die_gracefully(signal: int, frame: Optional[FrameType]) -> None:
if CURRENT_STATE == States.ZulipToZephyr:
# this is a child process, so we want os._exit (no clean-up necessary)
os._exit(1)
Expand Down
3 changes: 1 addition & 2 deletions zulip/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ def recur_expand(target_root: Any, dir: Any) -> Generator[Tuple[str, List[str]],
"License :: OSI Approved :: Apache Software License",
"Topic :: Communications :: Chat",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
python_requires=">=3.7",
python_requires=">=3.8",
url="https://www.zulip.org/",
project_urls={
"Source": "https://github.com/zulip/python-zulip-api/",
Expand Down
3 changes: 1 addition & 2 deletions zulip/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pkgutil
from typing import List

__path__: List[str] = pkgutil.extend_path(__path__, __name__)
__path__ = pkgutil.extend_path(__path__, __name__)
3 changes: 1 addition & 2 deletions zulip_bots/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
"License :: OSI Approved :: Apache Software License",
"Topic :: Communications :: Chat",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
python_requires=">=3.7",
python_requires=">=3.8",
url="https://www.zulip.org/",
project_urls={
"Source": "https://github.com/zulip/python-zulip-api/",
Expand Down
3 changes: 1 addition & 2 deletions zulip_botserver/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
"License :: OSI Approved :: Apache Software License",
"Topic :: Communications :: Chat",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
python_requires=">=3.7",
python_requires=">=3.8",
url="https://www.zulip.org/",
project_urls={
"Source": "https://github.com/zulip/python-zulip-api/",
Expand Down
3 changes: 1 addition & 2 deletions zulip_botserver/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pkgutil
from typing import List

__path__: List[str] = pkgutil.extend_path(__path__, __name__)
__path__ = pkgutil.extend_path(__path__, __name__)
4 changes: 3 additions & 1 deletion zulip_botserver/zulip_botserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def load_bot_handlers(
api_key=bots_config[bot]["key"],
site=bots_config[bot]["site"],
)
bot_dir = os.path.join(os.path.dirname(os.path.abspath(bot_lib_modules[bot].__file__)))
bot_file = bot_lib_modules[bot].__file__
assert bot_file is not None
bot_dir = os.path.dirname(os.path.abspath(bot_file))
bot_handler = lib.ExternalBotHandler(
client, bot_dir, bot_details={}, bot_config_parser=third_party_bot_conf
)
Expand Down
Loading