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

Pycode lint format v2 #14

Merged
merged 10 commits into from
Feb 22, 2023
Merged
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ coverage*

# pdoc documentation
docs

# pylint config file
!.pylintrc
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
profile=hug
src_paths=isort,test
178 changes: 178 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
[CUSTOM]

# allow all trailing whitespaces
[C0303(trailing-whitespace)]
disable=C0303

# disable recommend using enumerate in for loops
[C0200(consider-using-enumerate)]
disable=C0200

# allow unlimited number of instance attributes
[R0902(too-many-instance-attributes)]
disable=R0902

# allow dataframe cells to be directly assigned
[E1137(unsupported-assignment-operation)]
disable=E1137

# diable unsubscriptable object
[E1136(unsubscriptable-object)]
disable=E1136


# =======================================================================================
# =======================================================================================

[REPORTS]
# Python expression which should return a score less than or equal to 10. You
# have access to the variables 'fatal', 'error', 'warning', 'refactor',
# 'convention', and 'info' which contain the number of messages in each
# category, as well as 'statement' which is the total number of statements
# analyzed. This score is used by the global evaluation report (RP0004).
evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10))
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details.
msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
output-format=msvs
# Tells whether to display a full report or only the messages.
reports=yes
# Activate the evaluation score.
score=yes


[DESIGN]
# List of regular expressions of class ancestor names to ignore when counting
# public methods (see R0903)
exclude-too-few-public-methods=
# List of qualified class names to ignore when counting class parents (see R0901)
ignored-parents=
# Maximum number of arguments for function / method.
max-args=10
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
# Maximum number of branch for function / method body.
max-branches=15
# Maximum number of locals for function / method body.
max-locals=20
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body.
max-returns=5
# Maximum number of statements in function / method body.
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=2


[CLASSES]
# Warn about protected attribute access inside special methods
check-protected-access-in-special-methods=no
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__, __new__, setUp, __post_init__
# List of member names, which should be excluded from the protected access warning.
exclude-protected=_asdict, _fields, _replace, _source, _make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls


[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
expected-line-ending-format=
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=150
# Maximum number of lines in a module.
max-module-lines=1000
# Allow the body of a class to be on the same line as the declaration if body contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no else.
single-line-if-stmt=no


[STRING]
# This flag controls whether inconsistent-quotes generates a warning when the
# character used as a quote delimiter is used inconsistently within a module.
check-quote-consistency=no
# This flag controls whether the implicit-str-concat should generate a warning
# on implicit string concatenation in sequences defined over several lines.
check-str-concat-over-line-jumps=no


[LOGGING]
# The type of string formatting that logging methods do. `old` means using
# % formatting, `new` is for `{}` formatting.
logging-format-style=old
# Logging modules to check that the string format arguments are in logging
# function parameter format.
logging-modules=logging


[BASIC]
# Naming style matching correct argument names.
argument-naming-style=camelCase
# Naming style matching correct attribute names.
attr-naming-style=camelCase
# Regular expression matching correct attribute names. Overrides attr-naming-
# style. If left empty, attribute names will be checked with the set naming
# style.
attr-rgx=([a-z][a-zA-Z]|^_[a-z][a-zA-Z]|^__[a-z][a-zA-Z])
# Bad variable names which should always be refused, separated by a comma.
bad-names=foo, bar, baz, toto, tutu, tata
# Naming style matching correct class attribute names.
class-attribute-naming-style=camelCase
# Naming style matching correct class constant names.
class-const-naming-style=UPPER_CASE
# Naming style matching correct class names.
class-naming-style=PascalCase
# Naming style matching correct constant names.
const-naming-style=UPPER_CASE
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming style matching correct function names.
function-naming-style=camelCase
# Good variable names which should always be accepted, separated by a comma.
good-names=i, j, k, ex, run
# Include a hint for the correct naming format with invalid-name.
include-naming-hint=no
# Naming style matching correct inline iteration names.
inlinevar-naming-style=camelCase
# Naming style matching correct method names.
method-naming-style=camelCase
# Naming style matching correct module names.
module-naming-style=camelCase
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
# These decorators are taken in consideration only for invalid-name.
property-classes=abc.abstractproperty
# Naming style matching correct variable names.
variable-naming-style=camelCase


[SIMILARITIES]
# Comments are removed from the similarity computation
ignore-comments=yes
# Docstrings are removed from the similarity computation
ignore-docstrings=yes
# Imports are removed from the similarity computation
ignore-imports=yes
# Signatures are removed from the similarity computation
ignore-signatures=yes
# Minimum lines number of a similarity.
min-similarity-lines=4
63 changes: 38 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ loadpaths:
$(info DIR_VENV: $(DIR_VENV))
$(info DIR_DOCS: $(DIR_DOCS))
$(info DIR_IMAGES: $(DIR_IMAGES))
$(info DIR_LOGS: $(DIR_LOGS))

install_dependencies:
@ clear
Expand All @@ -29,35 +30,37 @@ install_dependencies:
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

opentcam_venv:
venv_opentcam:
clear
@ echo ------------------- Creating OpenTCAM Virtual Environment ------------------
@ echo " "
@ bash ${DIR_SCRIPTS}/setup_venv.sh
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

tcamtablemap:
sram_tablemap:
@ echo " "
@ echo ---------------------------- OpenTCAM Table Map ----------------------------
@ [ -d ${DIR_LOGS} ] || mkdir -p ${DIR_LOGS}
@ python3 $(DIR_COMP_SRC)/mainTableMapping.py \
--tcamConfig $(TCAMCONFIG) \
-excel $(EXCEL) -html $(HTML) -json $(JSON) -txt $(TXT) \
--debug $(DEBUG) --verbose $(VERBOSE)
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

tcamrtl:
tcam_rtl:
@ echo " "
@ echo ------------------------------- OpenTCAM RTL -------------------------------
@ [ -d ${DIR_LOGS} ] || mkdir -p ${DIR_LOGS}
@ python3 $(DIR_COMP_SRC)/mainTcamRTLGenerator.py \
--tcamWrapConfig $(TCAMWRAPCONFIG) \
--timeunit $(TIMEUNIT) --timeprecision $(TIMEPRECISION) \
--debug $(DEBUG) --verbose $(VERBOSE)
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

rununittest:
run_unittest:
@ echo " "
@ echo --------------------------- OpenTCAM Unit Test -----------------------------
@ python3 -m pytest -v -m ${MARKER} compiler/tests/*.py
Expand All @@ -66,7 +69,7 @@ rununittest:
# run single test using test_class_name and test_name
# @ python3 -m pytest -v compiler/tests/${TESTCLASS}.pytepy::${TESTCLASS}::${TESTNAME}

runregression:
run_regression:
@ echo " "
@ echo --------------------------- OpenTCAM Unit Tests ----------------------------
@ python3 -m pytest -v -s --ff --cache-clear ${DIR_COMP_TESTS}/*.py
Expand All @@ -80,7 +83,7 @@ testmarkers:
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

coverage:
run_coverage:
@ echo " "
@ echo -------------------------- OpenTCAM Test Coverage --------------------------
@ coverage erase
Expand All @@ -93,31 +96,42 @@ coverage:
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

apidocs:
gen_apidocs:
@ echo " "
@ echo ------------------------ OpenTCAM API Documentation ------------------------
@ pdoc ./compiler/src/tableMapping.py -o ${DIR_DOCS}
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

runpylint:
run_pylint:
@ echo " "
@ echo ------------------------------ Running PyLint ------------------------------
pylint ${DIR_COMP_SRC}/*.py --output-format=parseable:./logs/pylint.log,colorized \
--msg-template='{path:s}: (Ln {line:d}, Col {column}) -- {obj} -- {msg_id} -- {msg}' \
--rcfile=${OPENTCAM_ROOT}/.pylintrc
@ [ -d ${DIR_LOGS} ] || mkdir -p ${DIR_LOGS}
@ pylint ${DIR_COMP_SRC}/mainTableMapping.py \
--output-format=${FORMAT}:./logs/pylint.log,${COLOR} \
--score=${SCORE} --reports=${REPORTS} \
--rcfile=.pylintrc
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

runblack:
# @ pylint ${DIR_COMP_SRC}/*.py \

run_isort:
@ echo " "
@ echo ------------------------------ Running Black ------------------------------
@ black --check --target-version=py35 ${DIR_COMP_SRC}/*.py
@ echo ------------------------------ Running iSort ------------------------------
@ isort -v compiler/src/mainTableMapping.py
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

run_black:
@ echo " "
@ black --target-version=py35 ${DIR_COMP_SRC}/.py
@ echo ------------------------------ Running Black ------------------------------
@ black -v compiler/src/mainTableMapping.py
@ echo ---------------------------------- DONE -----------------------------------
@ echo " "

format_pycode: run_isort run_black

install_iverilog:
@ echo " "
@ echo ------------------------- INSTALLING Icarus Verilog ------------------------
Expand All @@ -132,58 +146,58 @@ install_yosys:
@ echo ----------------------------------- DONE -----------------------------------
@ echo " "

cleanvenv:
clean_venv:
@ echo " "
@ echo ------------------- Deleting Python Virtual Environment/s ------------------
@ echo " "
@ rm -rf .py* venv* .venv*
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

cleanlogs:
clean_logs:
@ echo " "
@ echo --------------------------- Deleting Log File/s ----------------------------
@ rm -rf logs
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

cleansramtables:
clean_sramtablemap:
@ echo " "
@ echo ---------------------- Deleting SRAM Table Map File/s ----------------------
@ rm -rf sramTables
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

cleanapidocs:
clean_apidocs:
@ echo " "
@ echo --------------------- Deleting API Documentation File/s --------------------
@ rm -rf docs
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

cleantcamrtl:
clean_tcamrtl:
@ echo " "
@ echo ------------------------- Deleting TCAM RTL File/s -------------------------
@ rm -rf tcam_mem_rtl
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

cleantests:
clean_tests:
@ echo " "
@ echo --------------------------- Deleting Test Cache ----------------------------
@ rm -rf ${DIR_COMP_TESTS}/.test_cache
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

cleancoverage:
clean_coverage:
@ echo " "
@ echo ------------------------- Deleting Coverage File/s -------------------------
@ rm -rf coverage* htmlcov .coverage
@ echo ------------------------------------ DONE ----------------------------------
@ echo " "

cleanall:
@ make cleanlogs cleansramtables cleantcamrtl cleantests cleancoverage cleanapidocs
clean_all:
@ make clean_logs clean_sramtablemap clean_tcamrtl clean_tests clean_coverage clean_apidocs

deepclean:
clear
Expand Down Expand Up @@ -241,4 +255,3 @@ help:
@ echo " "
@ echo ----------------------------------------------------------------------------
@ echo " "

Loading