50
50
import sys
51
51
import typing
52
52
import warnings
53
- from typing import Dict , List , Optional , TypeVar , Union , overload
53
+ from typing import Dict , List , Optional , Set , TypeVar , Union , overload
54
54
55
55
from astroid import bases
56
56
from astroid import decorators as decorators_mod
@@ -385,77 +385,30 @@ class Module(LocalsDictNodeNG):
385
385
386
386
_astroid_fields = ("body" ,)
387
387
388
- fromlineno = 0
389
- """The first line that this node appears on in the source code.
388
+ fromlineno : Literal [ 0 ] = 0
389
+ """The first line that this node appears on in the source code."""
390
390
391
- :type: int or None
392
- """
393
391
lineno : Literal [0 ] = 0
394
- """The line that this node appears on in the source code.
395
- """
392
+ """The line that this node appears on in the source code."""
396
393
397
394
# attributes below are set by the builder module or by raw factories
398
395
399
- file = None
400
- """The path to the file that this ast has been extracted from.
401
-
402
- This will be ``None`` when the representation has been built from a
403
- built-in module.
404
-
405
- :type: str or None
406
- """
407
- file_bytes = None
408
- """The string/bytes that this ast was built from.
396
+ file_bytes : Union [str , bytes , None ] = None
397
+ """The string/bytes that this ast was built from."""
409
398
410
- :type: str or bytes or None
411
- """
412
- file_encoding = None
399
+ file_encoding : Optional [str ] = None
413
400
"""The encoding of the source file.
414
401
415
402
This is used to get unicode out of a source file.
416
403
Python 2 only.
417
-
418
- :type: str or None
419
- """
420
- name = None
421
- """The name of the module.
422
-
423
- :type: str or None
424
- """
425
- pure_python = None
426
- """Whether the ast was built from source.
427
-
428
- :type: bool or None
429
- """
430
- package = None
431
- """Whether the node represents a package or a module.
432
-
433
- :type: bool or None
434
- """
435
- globals = None
436
- """A map of the name of a global variable to the node defining the global.
437
-
438
- :type: dict(str, NodeNG)
439
404
"""
440
405
441
- # Future imports
442
- future_imports = None
443
- """The imports from ``__future__``.
444
-
445
- :type: set(str) or None
446
- """
447
406
special_attributes = ModuleModel ()
448
- """The names of special attributes that this module has.
449
-
450
- :type: objectmodel.ModuleModel
451
- """
407
+ """The names of special attributes that this module has."""
452
408
453
409
# names of module attributes available through the global scope
454
410
scope_attrs = {"__name__" , "__doc__" , "__file__" , "__path__" , "__package__" }
455
- """The names of module attributes available through the global scope.
456
-
457
- :type: str(str)
458
- """
411
+ """The names of module attributes available through the global scope."""
459
412
460
413
_other_fields = (
461
414
"name" ,
@@ -475,53 +428,60 @@ class Module(LocalsDictNodeNG):
475
428
476
429
def __init__ (
477
430
self ,
478
- name ,
479
- doc ,
480
- file = None ,
431
+ name : str ,
432
+ doc : str ,
433
+ file : Optional [ str ] = None ,
481
434
path : Optional [List [str ]] = None ,
482
- package = None ,
483
- parent = None ,
484
- pure_python = True ,
485
- ):
435
+ package : Optional [ bool ] = None ,
436
+ parent : Literal [ None ] = None ,
437
+ pure_python : Optional [ bool ] = True ,
438
+ ) -> None :
486
439
"""
487
440
:param name: The name of the module.
488
- :type name: str
489
441
490
442
:param doc: The module docstring.
491
- :type doc: str
492
443
493
444
:param file: The path to the file that this ast has been extracted from.
494
- :type file: str or None
495
445
496
446
:param path:
497
- :type path: Optional[List[str]]
498
447
499
448
:param package: Whether the node represents a package or a module.
500
- :type package: bool or None
501
449
502
450
:param parent: The parent node in the syntax tree.
503
- :type parent: NodeNG or None
504
451
505
452
:param pure_python: Whether the ast was built from source.
506
- :type pure_python: bool or None
507
453
"""
508
454
self .name = name
455
+ """The name of the module."""
456
+
509
457
self .doc = doc
458
+ """The module docstring."""
459
+
510
460
self .file = file
461
+ """The path to the file that this ast has been extracted from.
462
+
463
+ This will be ``None`` when the representation has been built from a
464
+ built-in module.
465
+ """
466
+
511
467
self .path = path
468
+
512
469
self .package = package
470
+ """Whether the node represents a package or a module."""
471
+
513
472
self .pure_python = pure_python
473
+ """Whether the ast was built from source."""
474
+
475
+ self .globals : Dict [str , List [node_classes .NodeNG ]]
476
+ """A map of the name of a global variable to the node defining the global."""
477
+
514
478
self .locals = self .globals = {}
515
- """A map of the name of a local variable to the node defining the local.
516
479
517
- :type: dict(str, NodeNG)
518
- """
519
- self .body = []
520
- """The contents of the module.
480
+ self .body : Optional [List [node_classes .NodeNG ]] = []
481
+ """The contents of the module."""
521
482
522
- :type: list(NodeNG) or None
523
- """
524
- self .future_imports = set ()
483
+ self .future_imports : Set [str ] = set ()
484
+ """The imports from ``__future__``."""
525
485
526
486
super ().__init__ (lineno = 0 , parent = parent )
527
487
0 commit comments