Browse Source

Update Prospector to 1.2.0

This required a few minor changes/fixes:

* Change the name of an ignored pylint check about logging interpolation
* Add check=True to all subprocess.run() calls - this probably always
  should have been used so the scripts will crash if a command fails
* Remove a couple of unnecessary list comprehensions
* Ignore some warnings caused by mypy @hybrid_property workaround
merge-requests/88/head
Deimos 5 years ago
parent
commit
5c1a4dde44
  1. 5
      tildes/prospector.yaml
  2. 10
      tildes/requirements-dev.txt
  3. 12
      tildes/scripts/backup_database.py
  4. 2
      tildes/scripts/breached_passwords.py
  5. 2
      tildes/tildes/lib/html.py
  6. 2
      tildes/tildes/lib/string.py
  7. 2
      tildes/tildes/models/comment/comment.py
  8. 2
      tildes/tildes/models/topic/topic.py

5
tildes/prospector.yaml

@ -1,4 +1,5 @@
strictness: none
strictness: none # prevents using Prospector's default strictness profiles
doc-warnings: true
max-line-length: 88
@ -28,7 +29,7 @@ pylint:
- bad-continuation # let Black handle line-wrapping
- comparison-with-callable # seems to have a lot of false positives
- cyclic-import # not sure what's triggering this, doesn't seem to work correctly
- logging-fstring-interpolation # rather use f-strings than worry about this
- logging-format-interpolation # rather use f-strings than worry about this
- no-else-return # elif after return - could refactor to enable this check
- no-self-use # schemas do this a lot, would be nice to only disable for schemas
- too-few-public-methods # plenty of classes that don't need multiple methods

10
tildes/requirements-dev.txt

@ -3,7 +3,7 @@ alembic==1.3.2
amqpy==0.13.1
appdirs==1.4.3 # via black
argon2-cffi==19.2.0
astroid==2.2.5 # via prospector, pylint, pylint-celery, pylint-flask, requirements-detector
astroid==2.3.3 # via prospector, pylint, pylint-celery, pylint-flask, requirements-detector
attrs==19.3.0 # via black, pytest
backcall==0.1.0 # via ipython
beautifulsoup4==4.8.1
@ -49,7 +49,7 @@ plaster==1.0 # via plaster-pastedeploy, pyramid
pluggy==0.13.1 # via pytest
prometheus-client==0.7.1
prompt-toolkit==3.0.2 # via ipython
prospector==1.1.7
prospector==1.2.0
psycopg2==2.8.4
ptyprocess==0.6.0 # via pexpect
publicsuffix2==2.20160818
@ -57,14 +57,14 @@ py==1.8.0 # via pytest
pycodestyle==2.4.0 # via prospector
pycparser==2.19 # via cffi
pydocstyle==5.0.1 # via prospector
pyflakes==1.6.0 # via prospector
pyflakes==2.1.1 # via prospector
pygit2==1.0.0
pygments==2.5.2
pylint-celery==0.3 # via prospector
pylint-django==2.0.10 # via prospector
pylint-django==2.0.12 # via prospector
pylint-flask==0.6 # via prospector
pylint-plugin-utils==0.6 # via prospector, pylint-celery, pylint-django, pylint-flask
pylint==2.3.1 # via prospector, pylint-celery, pylint-django, pylint-flask, pylint-plugin-utils
pylint==2.4.4 # via prospector, pylint-celery, pylint-django, pylint-flask, pylint-plugin-utils
pyotp==2.3.0
pyparsing==2.4.5 # via packaging
pyramid-debugtoolbar==4.5.1

12
tildes/scripts/backup_database.py

@ -36,11 +36,14 @@ def create_encrypted_backup(gpg_recipient: str) -> str:
# dump the database to a file
with open(f"{filename}.sql", "w") as dump_file:
subprocess.run(
["pg_dump", "-U", "tildes", "tildes"], stdout=dump_file, text=True
["pg_dump", "-U", "tildes", "tildes"],
stdout=dump_file,
text=True,
check=True,
)
# gzip the dump file (replaces it)
subprocess.run(["gzip", "-9", f"{filename}.sql"])
subprocess.run(["gzip", "-9", f"{filename}.sql"], check=True)
# encrypt the compressed dump file using gpg
subprocess.run(
@ -52,7 +55,8 @@ def create_encrypted_backup(gpg_recipient: str) -> str:
"--recipient",
gpg_recipient,
f"{filename}.sql.gz",
]
],
check=True,
)
# delete the unencrypted dump file
@ -65,7 +69,7 @@ def upload_new_backup(host: str, gpg_recipient: str) -> None:
"""Create a new (encrypted) backup and then upload it to the FTP."""
new_filename = create_encrypted_backup(gpg_recipient)
subprocess.run(["lftp", "-e", f"put {new_filename}; bye", host])
subprocess.run(["lftp", "-e", f"put {new_filename}; bye", host], check=True)
logging.info(f"Successfully uploaded {new_filename} to FTP.")

2
tildes/scripts/breached_passwords.py

@ -128,7 +128,7 @@ def addhashes(filename: str) -> None:
# call wc to count the number of lines in the file for the progress bar
click.echo("Determining hash count...")
result = subprocess.run(["wc", "-l", filename], stdout=subprocess.PIPE)
result = subprocess.run(["wc", "-l", filename], stdout=subprocess.PIPE, check=True)
line_count = int(result.stdout.split(b" ")[0])
progress_bar: Any = click.progressbar(length=line_count)

2
tildes/tildes/lib/html.py

@ -16,7 +16,7 @@ def add_anchors_to_headings(html: str) -> str:
for heading in headings:
# generate an anchor from the string contents of the heading
anchor = convert_to_url_slug("".join([string for string in heading.strings]))
anchor = convert_to_url_slug("".join(heading.strings))
# create a link to that anchor, and put the heading's contents inside it
link = soup.new_tag("a", href=f"#{anchor}")

2
tildes/tildes/lib/string.py

@ -243,7 +243,7 @@ def extract_text_from_html(html: str, skip_tags: Optional[List[str]] = None) ->
html_tree = HTMLParser(namespaceHTMLElements=False).parseFragment(html)
# extract the text from all of the HTML elements
extracted_text = "".join([text for text in extract_text(html_tree, skip_tags)])
extracted_text = "".join(extract_text(html_tree, skip_tags))
# sanitize unicode, remove leading/trailing whitespace, etc.
return simplify_string(extracted_text)

2
tildes/tildes/models/comment/comment.py

@ -106,7 +106,7 @@ class Comment(DatabaseModel):
Index("ix_comments_search_tsv_gin", "search_tsv", postgresql_using="gin"),
)
@hybrid_property
@hybrid_property # pylint: disable=used-before-assignment
def markdown(self) -> str:
"""Return the comment's markdown."""
return self._markdown

2
tildes/tildes/models/topic/topic.py

@ -144,7 +144,7 @@ class Topic(DatabaseModel):
Index("ix_topics_search_tsv_gin", "search_tsv", postgresql_using="gin"),
)
@hybrid_property
@hybrid_property # pylint: disable=used-before-assignment
def markdown(self) -> Optional[str]:
"""Return the topic's markdown."""
if not self.is_text_type:

Loading…
Cancel
Save