Skip to content

Deepsource fixes #115

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

Merged
merged 8 commits into from
Sep 19, 2024
Merged
1 change: 1 addition & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enabled = true
dependency_file_paths = [
"requirements.txt",
"tests/requirements.txt",
"docs/requirements.txt",
"setup.py"
]

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Next-steps and bug-fixes are tracked [Here](https://github.com/users/reactive-fi

## License

### Copyright (c) 2021-2024, Mr. Walls

This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.

[![License - MIT](https://img.shields.io/github/license/reactive-firewall/multicast.svg?maxAge=3600)](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello W
[Here is how it is tested right now](https://github.com/reactive-firewall/multicast/blob/cdd577549c0bf7c2bcf85d1b857c86135778a9ed/tests/test_usage.py#L251-L554)

```python3
import multicast as multicast
import multicast
from multiprocessing import Process as Process

# set up some stuff
Expand Down
2 changes: 1 addition & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ p.start()
and elsewhere (like another function or even module) for the sender:
```python3

# assuming already did 'import multicast as multicast'
# assuming already did 'import multicast'

_fixture_SAY_args = [
"""--port""", _fixture_PORT_arg,
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
# see https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#syntax-directives

# be more like GFM with style
myst_enable_extensions = set(["tasklist", "strikethrough", "fieldlist"])
myst_enable_extensions = ("tasklist", "strikethrough", "fieldlist")

# for GFM diagrams and interoperability with other Markdown renderers
myst_fence_as_directive = ("mermaid", "suggestion", "note")
Expand Down
28 changes: 19 additions & 9 deletions multicast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@

__doc__ = __prologue__ + """

Dynamic Imports:
The sub-modules within "multicast" are interdependent, requiring access to each other's
functionalities. These statements import sub-modules of "multicast" and assign them to
aliases that match their sub-module names, facilitating organized access to these
components.
While the multicast alias is the same as the multicast module name, this pattern should
serve to reinforce the Multicast module's namespace, especially when dealing with dynamic
imports and to maintain consistency across different parts of the code.


Minimal Acceptance Testing:

First set up test fixtures by importing multicast.
Expand Down Expand Up @@ -564,12 +574,12 @@ def doStep(self, *args): # pragma: no cover

try:
if 'multicast.skt' not in sys.modules:
from . import skt
from . import skt as skt # pylint: disable=cyclic-import - skipcq: PLY-R0401, PYL-C0414
else: # pragma: no branch
skt = sys.modules["""multicast.skt"""]
except Exception as importErr:
del importErr
import multicast.skt as skt
import multicast.skt as skt # pylint: disable=cyclic-import - skipcq: PLY-R0401


genSocket = skt.genSocket
Expand All @@ -580,39 +590,39 @@ def doStep(self, *args): # pragma: no cover

try:
if 'multicast.recv' not in sys.modules:
from . import recv as recv
from . import recv as recv # pylint: disable=cyclic-import - skipcq: PLY-R0401
else: # pragma: no branch
recv = sys.modules["""multicast.recv"""]
except Exception as importErr:
del importErr
import multicast.recv as recv
import multicast.recv as recv # pylint: disable=cyclic-import - skipcq: PLY-R0401


try:
if 'multicast.send' not in sys.modules:
from . import send as send
from . import send as send # pylint: disable=cyclic-import - skipcq: PLY-R0401
else: # pragma: no branch
send = sys.modules["""multicast.send"""]
except Exception as importErr:
del importErr
import multicast.send as send
import multicast.send as send # pylint: disable=cyclic-import - skipcq: PLY-R0401


try:
if 'multicast.hear' not in sys.modules:
from . import hear as hear
from . import hear as hear # pylint: disable=cyclic-import - skipcq: PLY-R0401
else: # pragma: no branch
hear = sys.modules["""multicast.hear"""]
except Exception as importErr:
del importErr
import multicast.hear as hear
import multicast.hear as hear # pylint: disable=cyclic-import - skipcq: PLY-R0401


try:
if """multicast.__main__""" in sys.modules: # pragma: no cover
__main__ = sys.modules["""multicast.__main__"""]
except Exception:
import multicast.__main__ as __main__
import multicast.__main__ as __main__ # pylint: disable=cyclic-import - skipcq: PLY-R0401


if __name__ in u'__main__':
Expand Down
94 changes: 48 additions & 46 deletions multicast/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,39 @@

"""The Main Entrypoint.

Caution: See details regarding dynamic imports [documented](../__init__.py) in this module.

Minimal Acceptance Testing:

First set up test fixtures by importing multicast.

>>> import multicast as multicast
>>> import multicast as _multicast
>>>
>>> import multicast.__main__
>>> import _multicast.__main__
>>>

>>> multicast.__doc__ is not None
>>> _multicast.__doc__ is not None
True
>>>

>>> multicast.__main__.__doc__ is not None
>>> _multicast.__main__.__doc__ is not None
True
>>>

>>> multicast.__version__ is not None
>>> _multicast.__version__ is not None
True
>>>

Testcase 0: multicast.__main__ should have a doctests.

>>> import multicast.__main__
>>> import _multicast.__main__
>>>

>>> multicast.__main__.__module__ is not None
>>> _multicast.__main__.__module__ is not None
True
>>>

>>> multicast.__main__.__doc__ is not None
>>> _multicast.__main__.__doc__ is not None
True
>>>

Expand All @@ -76,80 +78,80 @@


try:
from . import sys as sys # skipcq: PYL-C0414
from . import sys as _sys
except Exception:
# Throw more relevant Error
raise ImportError(str("[CWE-440] Error Importing Python"))


try:
if 'multicast.__version__' not in sys.modules:
if 'multicast.__version__' not in _sys.modules:
from . import __version__ as __version__ # skipcq: PYL-C0414
else: # pragma: no branch
__version__ = sys.modules["""multicast.__version__"""]
__version__ = _sys.modules["""multicast.__version__"""]
except Exception as importErr:
del importErr
import multicast.__version__ as __version__ # noqa - used by --version argument.
import multicast.__version__ as __version__ # noqa. skipcq - used by --version argument.


try:
if 'multicast._MCAST_DEFAULT_PORT' not in sys.modules:
if 'multicast._MCAST_DEFAULT_PORT' not in _sys.modules:
from . import _MCAST_DEFAULT_PORT as _MCAST_DEFAULT_PORT # skipcq: PYL-C0414
else: # pragma: no branch
_MCAST_DEFAULT_PORT = sys.modules["""multicast._MCAST_DEFAULT_PORT"""]
_MCAST_DEFAULT_PORT = _sys.modules["""multicast._MCAST_DEFAULT_PORT"""]
except Exception as importErr:
del importErr
import multicast._MCAST_DEFAULT_PORT as _MCAST_DEFAULT_PORT
import multicast._MCAST_DEFAULT_PORT as _MCAST_DEFAULT_PORT # skipcq - used by port argument.


try:
if 'multicast._MCAST_DEFAULT_GROUP' not in sys.modules:
if 'multicast._MCAST_DEFAULT_GROUP' not in _sys.modules:
from . import _MCAST_DEFAULT_GROUP as _MCAST_DEFAULT_GROUP # skipcq: PYL-C0414
else: # pragma: no branch
_MCAST_DEFAULT_GROUP = sys.modules["""multicast._MCAST_DEFAULT_GROUP"""]
_MCAST_DEFAULT_GROUP = _sys.modules["""multicast._MCAST_DEFAULT_GROUP"""]
except Exception as importErr:
del importErr
import multicast._MCAST_DEFAULT_GROUP as _MCAST_DEFAULT_GROUP
import multicast._MCAST_DEFAULT_GROUP as _MCAST_DEFAULT_GROUP # skipcq - used by group arg.


try:
if 'multicast.mtool' not in sys.modules:
if 'multicast.mtool' not in _sys.modules:
from . import mtool as mtool # skipcq: PYL-C0414
else: # pragma: no branch
mtool = sys.modules["""multicast.mtool"""]
mtool = _sys.modules["""multicast.mtool"""]
except Exception as importErr:
del importErr
import multicast.mtool as mtool
import multicast.mtool as mtool # noqa - used by all arguments' CMD (sub-command).


try:
if 'multicast.recv' not in sys.modules:
from . import recv as recv # skipcq: PYL-C0414
if 'multicast.recv' not in _sys.modules:
from . import recv as recv # pylint: disable=useless-import-alias - skipcq: PYL-C0414
else: # pragma: no branch
recv = sys.modules["""multicast.recv"""]
recv = _sys.modules["""multicast.recv"""]
except Exception as importErr:
del importErr
import multicast.recv as recv
import multicast.recv as recv # pylint: disable=useless-import-alias - skipcq: PYL-C0414


try:
if 'multicast.send' not in sys.modules:
from . import send as send # skipcq: PYL-C0414
if 'multicast.send' not in _sys.modules:
from . import send as send # pylint: disable=useless-import-alias - skipcq: PYL-C0414
else: # pragma: no branch
send = sys.modules["""multicast.send"""]
send = _sys.modules["""multicast.send"""]
except Exception as importErr:
del importErr
import multicast.send as send
import multicast.send as send # pylint: disable=useless-import-alias - skipcq: PYL-C0414


try:
if 'multicast.hear' not in sys.modules:
from . import hear as hear # skipcq: PYL-C0414
if 'multicast.hear' not in _sys.modules:
from . import hear as hear # pylint: disable=useless-import-alias - skipcq: PYL-C0414
else: # pragma: no branch
hear = sys.modules["""multicast.hear"""]
hear = _sys.modules["""multicast.hear"""]
except Exception as importErr:
del importErr
import multicast.hear as hear
import multicast.hear as hear # pylint: disable=useless-import-alias - skipcq: PYL-C0414


class McastNope(mtool):
Expand Down Expand Up @@ -447,12 +449,12 @@ def doStep(self, *args, **kwargs):
# More boiler-plate-code


TASK_OPTIONS = dict({
'NOOP': McastNope(),
'RECV': McastRecvHearDispatch(),
'SAY': send.McastSAY(),
'HEAR': McastRecvHearDispatch(),
})
TASK_OPTIONS = {
"""NOOP""": McastNope(),
"""RECV""": McastRecvHearDispatch(),
"""SAY""": send.McastSAY(),
"""HEAR""": McastRecvHearDispatch(),
}
"""The callable function tasks of this program. will add."""


Expand Down Expand Up @@ -501,13 +503,13 @@ def doStep(self, *args):
_TOOL_MSG = (self.useTool(service_cmd, **argz.__dict__))
if _TOOL_MSG[0]:
__EXIT_MSG = (0, _TOOL_MSG)
elif (sys.stdout.isatty()): # pragma: no cover
elif (_sys.stdout.isatty()): # pragma: no cover
print(_TOOL_MSG)
except Exception as inerr: # pragma: no branch
w = str("WARNING - An error occurred while")
w += str(" handling the arguments.")
w += str(" Refused.")
if (sys.stdout.isatty()): # pragma: no cover
if (_sys.stdout.isatty()): # pragma: no cover
print(w)
print(str(inerr))
print(str(inerr.args))
Expand All @@ -516,7 +518,7 @@ def doStep(self, *args):
except BaseException: # pragma: no branch
e = str("CRITICAL - An error occurred while handling")
e += str(" the dispatch.")
if (sys.stdout.isatty()): # pragma: no cover
if (_sys.stdout.isatty()): # pragma: no cover
print(str(e))
__EXIT_MSG = (3, "STOP")
return __EXIT_MSG # noqa
Expand All @@ -536,7 +538,7 @@ def main(*argv):
= 3: Any undefined (but assumed erroneous) state
> 0: implicitly erroneous and treated same as abs(exit_code) would be.

param iterable - argv - the array of arguments. Usually sys.argv[1:]
param iterable - argv - the array of arguments. Usually _sys.argv[1:]
returns int - the Namespace parsed with the key-value pairs.

Minimal Acceptance Testing:
Expand Down Expand Up @@ -601,8 +603,8 @@ def main(*argv):

if __name__ in '__main__':
__EXIT_CODE = (2, "NoOp")
if (sys.argv is not None) and (len(sys.argv) > 1):
__EXIT_CODE = main(sys.argv[1:])
elif (sys.argv is not None):
if (_sys.argv is not None) and (len(_sys.argv) > 1):
__EXIT_CODE = main(_sys.argv[1:])
elif (_sys.argv is not None):
__EXIT_CODE = main([str(__name__), """-h"""])
exit(__EXIT_CODE[0])
Loading
Loading