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

Switch from setup.py to pyproject.toml #1111

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
custom pylint
  • Loading branch information
patricklnz committed Sep 26, 2024
commit 26b7c01f4ffc4375b1e9dfb1f3de26bd1d3b955c
50 changes: 50 additions & 0 deletions pycode/memilio-epidata/memilio/custom_pylint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from setuptools import Command, Distribution
import os

__version__ = '1.0.0'

class PylintCommand(Command):
"""
Custom command to run pylint and get a report as html.
"""
description = "Runs pylint and outputs the report as html."
user_options = []

def initialize_options(self):
from pylint.reporters.json_reporter import JSONReporter
from pylint.reporters.text import ParseableTextReporter, TextReporter
from pylint_json2html import JsonExtendedReporter

self.lint_modules = ["memilio/"]
self.out_format = "extendedjson"

self.REPORTERS = {
"parseable": (ParseableTextReporter, "build_pylint/pylint_parseable.txt"),
"text": (TextReporter, "build_pylint/pylint.txt"),
"json": (JSONReporter, "build_pylint/pylint.json"),
"extendedjson": (JsonExtendedReporter, "build_pylint/pylint_extended.json")
}

def finalize_options(self):
self.reporter, self.out_file = self.REPORTERS.get(
self.out_format)

def run(self):
os.makedirs("build_pylint", exist_ok=True)

# Run pylint
from pylint import lint
with open(self.out_file, "w", encoding="utf-8") as report_file:
options = ["--rcfile=../pylintrc", *self.lint_modules]

lint.Run(options, reporter=self.reporter(
report_file), do_exit=False)

def main():
cmd = PylintCommand(dist=Distribution())
cmd.initialize_options()
cmd.finalize_options()
cmd.run()

if __name__ == "__main__":
main()
10 changes: 1 addition & 9 deletions pycode/memilio-epidata/pyproject.toml
Original file line number Diff line number Diff line change
@@ -2,9 +2,6 @@
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = [ "memilio.epidata", "memilio.epidata_test"]

[project]
name = "memilio-epidata"
version = "1.0.0"
@@ -62,9 +59,4 @@ cleandata = "memilio.epidata.cleanData:main"
getcommutermobility = "memilio.epidata.getCommuterMobility:main"
getvaccinationdata = "memilio.epidata.getVaccinationData:main"
gethospitalizationdata = "memilio.epidata.getHospitalizationData:main"

[tool.pylint]
max-line-length = 120
source-roots = "memilio/"
sugestion-mode = true
exit-zero = true #Always return a non-error status code
pylint = "memilio.custom_pylint:main"
Loading